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

pump.Storage: fix possible panic if start ts is greater than max commit ts when pull binlog #758

Merged
merged 6 commits into from
Sep 30, 2019

Conversation

WangXiangUSTC
Copy link
Contributor

What problem does this PR solve?

in pull binlog, if start ts is greater than max commit ts, pump may panic because goleveldb's bug syndtr/goleveldb#224

What is changed and how it works?

add a check in storage
and update some log by the way

Check List

Tests

  • Manual test

Related changes

  • Need to cherry-pick to the release branch

pump/storage/sorter.go Outdated Show resolved Hide resolved
Co-Authored-By: Ian <ArGregoryIan@gmail.com>
limitTS := atomic.LoadInt64(&a.maxCommitTS) + 1
if startTS > limitTS {
log.Warn("last ts is greater than pump's max commit ts", zap.Int64("last ts", startTS-1), zap.Int64("max commit ts", limitTS-1))
time.Sleep(time.Second * 10)
Copy link
Collaborator

@IANTHEREAL IANTHEREAL Sep 30, 2019

Choose a reason for hiding this comment

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

10 second is too long, how about return directly and let client to handle when to pull again

Copy link
Collaborator

Choose a reason for hiding this comment

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

if so, you also need to check logic of drainer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can't return here, otherwise, drainer will not get binlog forever and need restart

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and this need update a lot of code, I think just wait is ok

Copy link
Collaborator

@IANTHEREAL IANTHEREAL Sep 30, 2019

Choose a reason for hiding this comment

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

10 seconds is too long

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update to 1 second

@IANTHEREAL
Copy link
Collaborator

Rest LGTM

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -1114,9 +1115,15 @@ func (a *Append) PullCommitBinlog(ctx context.Context, last int64) <-chan []byte

for {
startTS := last + 1
limitTS := atomic.LoadInt64(&a.maxCommitTS) + 1
if startTS > limitTS {
Copy link
Contributor

@july2993 july2993 Sep 30, 2019

Choose a reason for hiding this comment

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

just set limitTS to be startTS + 1 if startTS >= limitTS to by pass the bug
don't log warn log and sleep 10 second

and add some commend about the bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will it cause some bug if query some binlog is greater than the max commit ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add a comment

Copy link
Contributor

@july2993 july2993 Sep 30, 2019

Choose a reason for hiding this comment

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

correct:
set limitTS to be startTS if startTS > limitTS if the bug about goleveldb will only trigger when
start > limit

[startTS, limitTS = startTS) will get no any binlog

@IANTHEREAL
Copy link
Collaborator

LGTM

if startTS > limitTS {
// if range's start is greater than limit, may cause panic, see https://github.com/syndtr/goleveldb/issues/224 for detail.
pLog.Print(labelWrongRange, func() {
log.Warn("last ts is greater than pump's max commit ts", zap.Int64("last ts", startTS-1), zap.Int64("max commit ts", limitTS-1))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually a normal case, so don't add warn log.

like the MaxCommitTS = 10 in pump, checkpointTS = 10 for drainer,
so check for if we having newer binlogs by [checkpointTS + 1, MaxCommitTS + 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in normal case startTS is equal to limitTS, but will not greater than it?

Copy link
Contributor

Choose a reason for hiding this comment

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

look yes, but why will trigger this?

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

LGTM

@july2993
Copy link
Contributor

/run-all-tests tidb=release-3.0 tikv=release-3.0 pd=release-3.0

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

Successfully merging this pull request may close these issues.

3 participants