Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions downstreamadapter/dispatcher/event_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ func (d *EventDispatcher) Remove() {
d.removeDispatcher()
}

// EmitBootstrap emits the table bootstrap event in a blocking way after changefeed started
// It will return after the bootstrap event is sent.
func (d *EventDispatcher) EmitBootstrap() bool {
// EmitBootstrap emits the table bootstrap event in a blocking way after changefeed started.
// It will return after the bootstrap event is sent, or when shouldStop asks it
// to stop because the local write path has been fenced.
func (d *EventDispatcher) EmitBootstrap(shouldStop func() bool) bool {
bootstrap := loadBootstrapState(&d.BootstrapState)
switch bootstrap {
case BootstrapFinished:
Expand Down Expand Up @@ -204,9 +205,15 @@ func (d *EventDispatcher) EmitBootstrap() bool {
if table.IsView() {
continue
}
if shouldStop() {
return false
}
ddlEvent := codec.NewBootstrapDDLEvent(table)
err := d.sink.WriteBlockEvent(ddlEvent)
if err != nil {
if shouldStop() {
return false
}
log.Error("send bootstrap message failed",
zap.Stringer("changefeed", d.sharedInfo.changefeedID),
zap.Int("tables", len(currentTables)),
Expand All @@ -216,6 +223,9 @@ func (d *EventDispatcher) EmitBootstrap() bool {
d.HandleError(errors.ErrExecDDLFailed.GenWithStackByArgs())
return true
}
if shouldStop() {
return false
}
}
storeBootstrapState(&d.BootstrapState, BootstrapFinished)
log.Info("send bootstrap messages finished",
Expand Down
Loading
Loading