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

bindinfo: fix panic when load invalid sqls #14645

Merged
merged 2 commits into from
Feb 5, 2020
Merged

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Feb 5, 2020

What problem does this PR solve?

When sqls in the bind_info table is not valid, it will panic in Update.

What is changed and how it works?

It panics in

		hash, meta, err := h.newBindMeta(newBindRecord(row))
		// Update lastUpdateTime to the newest one.
		if meta.UpdateTime.Compare(h.lastUpdateTime) > 0 {
			h.lastUpdateTime = meta.UpdateTime
		}

The invalid sql would cause error in newBindMeta, and the meta is nil, so it cause panic in following lines. This PR does not fixes it by check err first because we need to update the lastUpdateTime to avoid fail in next Update.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

  • None

Release note

  • fix panic when load invalid bind records into cache

@alivxxx alivxxx added the type/bugfix This PR fixes a bug. label Feb 5, 2020
Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@lzmhhh123 lzmhhh123 added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 5, 2020
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 5, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Feb 5, 2020

/run-all-tests

@zz-jason
Copy link
Member

zz-jason commented Feb 5, 2020

do we have this bug in master branch?

@sre-bot sre-bot merged commit c8d9c79 into pingcap:release-3.0 Feb 5, 2020
@alivxxx
Copy link
Contributor Author

alivxxx commented Feb 5, 2020

@zz-jason No

@alivxxx alivxxx deleted the panic branch February 5, 2020 09:00
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. 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.

5 participants