Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add succ filed to slow log and fix shallow copy problem when parse slow log file. #11417

Merged
merged 13 commits into from
Jul 24, 2019

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Jul 24, 2019

What problem does this PR solve?

  • Add Succ filed name to slow log and SLOW_QUERY table.
  • change SLOW_QUERY,Query column type from varchar(4096) to longtext.
  • fix shallow copy problem caused by the long query(len(query) > 4094).

What is changed and how it works?

  • Add copy for getOneLine function.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

Related changes

  • Need to cherry-pick to the release branch

@crazycs520 crazycs520 added type/bugfix This PR fixes a bug. type/usability labels Jul 24, 2019
@crazycs520 crazycs520 changed the title Refine slow log slow_log: add succ filed to slow log and fix shallow copy problem. Jul 24, 2019
@crazycs520
Copy link
Contributor Author

@zz-jason @zimulala PTAL

@codecov
Copy link

codecov bot commented Jul 24, 2019

Codecov Report

Merging #11417 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11417   +/-   ##
===========================================
  Coverage   81.3926%   81.3926%           
===========================================
  Files           424        424           
  Lines         90733      90733           
===========================================
  Hits          73850      73850           
  Misses        11585      11585           
  Partials       5298       5298

@Deardrops
Copy link
Contributor

How many bytes in query string will cause the shallow copy problem?

@crazycs520
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crazycs520
Copy link
Contributor Author

@Deardrops When the length of query more than 4094.

case variable.SlowLogSucc:
succ, err := strconv.ParseBool(value)
if err != nil {
return errors.AddStack(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use errors.Wrap() to explain which operation causes this error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks, Done.
I add errors.Wrap() outside of this function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to wrap it here? Why delaying it to the outside?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

infoschema/slow_log.go Outdated Show resolved Hide resolved
@@ -120,14 +120,14 @@ func ParseSlowLog(tz *time.Location, reader *bufio.Reader) ([][]types.Datum, err
}
err = st.setFieldValue(tz, field, fieldValues[i+1])
if err != nil {
return rows, err
return rows, errors.Wrap(err, "parse slow log filed `"+field+"` error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

infoschema/slow_log.go Outdated Show resolved Hide resolved
infoschema/slow_log.go Outdated Show resolved Hide resolved
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. needs-cherry-pick-2.1 labels Jul 24, 2019
@zz-jason
Copy link
Member

@crazycs520 crazycs520 changed the title slow_log: add succ filed to slow log and fix shallow copy problem. *: add succ filed to slow log and fix shallow copy problem when parse slow log file. Jul 24, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Jul 24, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Jul 24, 2019

success

@sre-bot sre-bot merged commit 86d8f9a into pingcap:master Jul 24, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Jul 24, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Jul 24, 2019

cherry pick to release-3.0 failed

@@ -159,3 +172,17 @@ select * from t;`)
_, err = infoschema.ParseSlowLog(loc, scanner)
c.Assert(err, IsNil)
}

func (s *testSuite) TestSlowLogLongQuery(c *C) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, This test is redundant, I will remove this test.

crazycs520 added a commit to crazycs520/tidb that referenced this pull request Jul 24, 2019
sre-bot pushed a commit that referenced this pull request Jul 25, 2019
…e slow log file. (#11417) (#11419)

All tests passed, auto merged by Bot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug. type/usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants