Skip to content

executor: fix panic when fetching processlist table data in some cases#11688

Merged
sre-bot merged 2 commits into
pingcap:masterfrom
qw4990:spl-panic
Aug 12, 2019
Merged

executor: fix panic when fetching processlist table data in some cases#11688
sre-bot merged 2 commits into
pingcap:masterfrom
qw4990:spl-panic

Conversation

@qw4990
Copy link
Copy Markdown
Contributor

@qw4990 qw4990 commented Aug 8, 2019

What problem does this PR solve?

When TiDB fetches data from processlist table, it will get each connection's memory consumption according to their Ctx.Memtracker.
But in some cases, Ctx.Memtracker is not initialized at that time, which results in a panic.

What is changed and how it works?

Check if Ctx.Memtracker is nil before using it when fetching processlist table data.

@qw4990 qw4990 added type/bugfix This PR fixes a bug. sig/execution SIG execution labels Aug 8, 2019
@qw4990 qw4990 requested review from lysu, tiancaiamao and zz-jason August 8, 2019 11:12
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 8, 2019

Codecov Report

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

@@             Coverage Diff             @@
##             master     #11688   +/-   ##
===========================================
  Coverage   81.4407%   81.4407%           
===========================================
  Files           429        429           
  Lines         92746      92746           
===========================================
  Hits          75533      75533           
  Misses        11821      11821           
  Partials       5392       5392

Copy link
Copy Markdown
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
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.

Could you add some UT?

Copy link
Copy Markdown
Contributor

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@qw4990
Copy link
Copy Markdown
Contributor Author

qw4990 commented Aug 9, 2019

Could you add some UT?

It's hard to write some unit tests for this case.
The state of a Conn is complex so it's hard to construct an appropriate Conn to trigger this bug.

Actually, to locate this problem, I create an individual goroutine for each Conn when it comes.
This individual goroutine executes a dead loop to find the invalid state of this Coon:

for {
    If conn.ProcessInfo() != nil && conn.Ctx.MemTracker == nil {
        panic("invalid state")
    }
}

It's not appropriate to write dead loops in our unit tests.
PTAL. @zz-jason

@winkyao winkyao added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Aug 11, 2019
@qw4990
Copy link
Copy Markdown
Contributor Author

qw4990 commented Aug 12, 2019

PTAL @zz-jason

Copy link
Copy Markdown
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. status/LGT2 Indicates that a PR has LGTM 2. labels Aug 12, 2019
@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 12, 2019

/run-all-tests

@sre-bot sre-bot merged commit a08918a into pingcap:master Aug 12, 2019
@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 12, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @qw4990 PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants