-
Notifications
You must be signed in to change notification settings - Fork 130
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
ddl: save checkpoint with schemaVersion #1033
Conversation
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
drainer/checkpoint/file.go
Outdated
@@ -92,6 +93,7 @@ func (sp *FileCheckPoint) Save(ts, secondaryTS int64, consistent bool) error { | |||
|
|||
sp.CommitTS = ts | |||
sp.ConsistentSaved = consistent | |||
sp.Version = version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prevent the version being reduced here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A recently test case shows that drainer writes the old schema version again after manually adjusting the schema version to the correct value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test case with amend transaction enabled.
dml | ddl | schema version |
---|---|---|
begin | 1 | |
insert... | ||
ddls | from 1 to 10 | |
commit | 10 |
The ddls are executed before transaction committed and push the schema version to 10 in checkpoint. When the drainer is executing the dml transaction, the schema version of it is still 1, and will checkpoint with schema version 1 into checkpoint.
drainer/syncer.go
Outdated
eventCounter.WithLabelValues("savepoint").Add(1) | ||
} | ||
|
||
log.Info("handleSuccess quit") | ||
} | ||
|
||
func (s *Syncer) savePoint(ts, secondaryTS int64) { | ||
func (s *Syncer) savePoint(ts, secondaryTS, version int64) { | ||
if ts < s.cp.TS() { | ||
log.Error("save ts is less than checkpoint ts %d", zap.Int64("save ts", ts), zap.Int64("checkpoint ts", s.cp.TS())) | ||
} | ||
|
||
log.Info("write save point", zap.Int64("ts", ts)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May also log version in this function.
Co-authored-by: you06 <you1474600@gmail.com>
…/tidb-binlog into fix_load_schema_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
What problem does this PR solve?
Fix #1032
What is changed and how it works?
save schemaVersion to checkpoint.
with amend txn enabled.
prewrite.SchemeVersion
could out of date.so when drainer restart, we need to compare
checkpoint'SchemaVersion
andprewrite.SchemaVersion
.Check List
Tests
Related changes
Release note