Skip to content

Commit 1e7caec

Browse files
committed
maintainer: fix panic when maintainer into bootstrap after removing maintainer (#3222)
close #3221
1 parent 8821efa commit 1e7caec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

maintainer/maintainer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,11 @@ func newDDLSpan(keyspaceID uint32, cfID common.ChangeFeedID, checkpointTs uint64
888888
}
889889

890890
func (m *Maintainer) onBootstrapDone(cachedResp map[node.ID]*heartbeatpb.MaintainerBootstrapResponse) {
891-
if cachedResp == nil {
891+
// calCheckpointTs() skips advancing checkpoint when bootstrapped is false, so it won't call
892+
// onNodeChanged() before FinishBootstrap succeeds. All other callers of onNodeChanged() and
893+
// onMaintainerBootstrapResponse() run in the same event loop goroutine as onRemoveMaintainer(),
894+
// hence guarding with m.removing is sufficient to avoid accessing a removed DDL span leading to panic.
895+
if cachedResp == nil || m.removing.Load() {
892896
return
893897
}
894898
isMySQLSinkCompatible, err := isMysqlCompatible(m.info.SinkURI)

0 commit comments

Comments
 (0)