Skip to content

Commit

Permalink
sinkV2(ticdc): sink manager close the sink factory at the last (#8219) (
Browse files Browse the repository at this point in the history
#8227)

close #8216
  • Loading branch information
ti-chi-bot authored Feb 14, 2023
1 parent bdd1226 commit 5db19d1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cdc/processor/sinkmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,10 +878,6 @@ func (m *SinkManager) Close() error {
}
m.sinkMemQuota.Close()
m.redoMemQuota.Close()
err := m.sinkFactory.Close()
if err != nil {
return errors.Trace(err)
}
m.tableSinks.Range(func(key, value interface{}) bool {
sink := value.(*tableSinkWrapper)
sink.close(m.ctx)
Expand All @@ -890,11 +886,18 @@ func (m *SinkManager) Close() error {
}
return true
})
m.wg.Wait()
log.Info("All table sinks closed",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
zap.Duration("cost", time.Since(start)))
m.wg.Wait()
// todo: Add a unit test to cover this,
// Make sure all sink workers exited before closing the sink factory.
// Otherwise, it would panic in the sink when you try to write some data to a closed sink.
err := m.sinkFactory.Close()
if err != nil {
return errors.Trace(err)
}
log.Info("Closed sink manager",
zap.String("namespace", m.changefeedID.Namespace),
zap.String("changefeed", m.changefeedID.ID),
Expand Down

0 comments on commit 5db19d1

Please sign in to comment.