-
Notifications
You must be signed in to change notification settings - Fork 188
shard DDL: rewrite shard DDL in pessimism mode for HA #456
Conversation
@WangXiangUSTC @lichunzhu PTAL |
dm/master/shardddl/pessimist.go
Outdated
p.lk.Clear() // clear all previous locks to support re-Start. | ||
|
||
// get the history shard DDL info. | ||
ifm, rev, err := pessimism.GetAllInfo(etcdCli) |
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.
Shall we synchronize the variable name of rev
to revision-W1
in the explannation go program?
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.
add the ref to doc.go in 3ae58b6.
dm/master/shardddl/pessimist.go
Outdated
p.wg.Done() | ||
close(opCh) | ||
}() | ||
pessimism.WatchOperationPut(ctx, etcdCli, "", "", rev, opCh) |
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 this rev
be rev2
?
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.
rev
can work correctly because rev < rev2
, but rev2
is more readable, updated in 3ae58b6.
/run-all-tests tidb=release-3.0 |
shardLockResolving.WithLabelValues(s.cfg.Name).Set(0) | ||
break | ||
shardOp, err2 := s.pessimist.GetOperation(ec.tctx.Ctx, shardInfo, rev) | ||
shardLockResolving.WithLabelValues(s.cfg.Name).Set(0) |
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.
do this after err2 is nil?
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.
YES, if err2 == nil
, syncer will abort the replication, then it's not waiting for the lock to be resolved anymore, but can be in resolving after resumed without error.
Co-Authored-By: WangXiangUSTC <wx347249478@gmail.com>
/run-all-tests tidb=release-3.0 |
Codecov Report
@@ Coverage Diff @@
## ha-dev #456 +/- ##
===========================================
Coverage ? 54.4227%
===========================================
Files ? 174
Lines ? 16890
Branches ? 0
===========================================
Hits ? 9192
Misses ? 6780
Partials ? 918 |
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.
Rest LGTM
dm/master/shardddl/pessimist.go
Outdated
lk *pessimism.LockKeeper | ||
|
||
// sources used to get all sources relative to the give task. | ||
sources func(task string) []string |
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.
How about refract to taskSources
or getTaskSources
? sources
seems weird.
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.
renamed in e2972a2.
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.
rest LGTM
pkg/shardddl/pessimism/ops.go
Outdated
|
||
resp, err := cli.Txn(ctx).Then(putOp, delOp).Commit() | ||
if err != nil { | ||
return 0, nil |
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.
return err?
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.
Good catch! fixed in e2972a2.
/run-all-tests tidb=release-3.0 |
@lichunzhu @WangXiangUSTC PTAL again. |
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
What problem does this PR solve?
What is changed and how it works?
StreamerController
Things have not to be done in this PR (I'll do them in the next PR)
terror
for shard DDL in pessimism modeunlock-ddl-lock
)Check List
Tests
Code changes
Side effects
Related changes