Campaign returned at line 79 so e.leaderKey is not assigned. Another clue (need to check) is that the error is etcdserver: request timed out which means the success of committing is undeterminated.
and soon we watched the election key, so above commit is successful.
but current election is failed because of etcdserver: request timed out, so we can't delete that key by Resign when evict leader.
and next time we enter the compaign loop, we skip Campaign because e.evictLeader.Load(), so we have no chance to inherit the election key of last time and further delete it by Resign. So the orphanic election key have no change to be deleted. This causes the DM-master always become leader
Bug Report
re-explain of https://github.com/pingcap/dm/issues/1212
Please answer these questions before submitting your issue. Thanks!
evict leader
evict success
leader can't be evicted
dm-ci.log.zip
in the log we can see
the current election key (consist of a user specified prefix and etcd session lease) is
/dm-master/leader/690e7b3305c06104
last election ends gracefully
start a new election
this new election failed, and the inner recorded election key is empty
this is caused by in
https://github.com/etcd-io/etcd/blob/ea24fb850762ce38155738aff5ae71368eadb904/client/v3/concurrency/election.go#L69-L81
Campaign
returned at line 79 soe.leaderKey
is not assigned. Another clue (need to check) is that the error isetcdserver: request timed out
which means the success of committing is undeterminated.and soon we watched the election key, so above commit is successful.
but current election is failed because of
etcdserver: request timed out
, so we can't delete that key byResign
when evict leader.and next time we enter the compaign loop, we skip
Campaign
becausee.evictLeader.Load()
, so we have no chance to inherit the election key of last time and further delete it byResign
. So the orphanic election key have no change to be deleted. This causes the DM-master always become leaderhttps://github.com/pingcap/dm/blob/4868d4e011f445c7bc89fc3168483862b51b6302/pkg/election/election.go#L261-L268