Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sink(ticdc): asynchronously close the mq producers #5186

Merged
merged 15 commits into from
Apr 19, 2022
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
5 changes: 4 additions & 1 deletion cdc/owner/ddl_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,8 @@ func (s *ddlSinkImpl) close(ctx context.Context) (err error) {
err = s.syncPointStore.Close()
}
s.wg.Wait()
return err
if err != nil && errors.Cause(err) != context.Canceled {
return err
}
return nil
}
4 changes: 2 additions & 2 deletions cdc/processor/pipeline/table_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func NewTableActor(cdcCtx cdcContext.Context,

startTime := time.Now()
log.Info("table actor starting",
zap.String("changefeed", changefeedVars.ID),
zap.String("changefeed", table.changefeedID),
zap.String("tableName", tableName),
zap.Int64("tableID", tableID))
if err := table.start(cctx); err != nil {
Expand All @@ -152,7 +152,7 @@ func NewTableActor(cdcCtx cdcContext.Context,
return nil, errors.Trace(err)
}
log.Info("table actor started",
zap.String("changefeed", changefeedVars.ID),
zap.String("changefeed", table.changefeedID),
zap.String("tableName", tableName),
zap.Int64("tableID", tableID),
zap.Duration("duration", time.Since(startTime)))
Expand Down
13 changes: 3 additions & 10 deletions cdc/sink/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"context"
"sync"
"sync/atomic"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/log"
Expand Down Expand Up @@ -83,18 +82,12 @@ func (m *Manager) Close(ctx context.Context) error {
defer m.tableSinksMu.Unlock()
tableSinkTotalRowsCountCounter.DeleteLabelValues(m.changefeedID)
if m.bufSink != nil {
log.Info("sinkManager try close bufSink",
zap.String("changefeed", m.changefeedID))
start := time.Now()
if err := m.bufSink.Close(ctx); err != nil {
log.Info("close bufSink failed",
if err := m.bufSink.Close(ctx); err != nil && errors.Cause(err) != context.Canceled {
log.Warn("close bufSink failed",
zap.String("changefeed", m.changefeedID),
zap.Duration("duration", time.Since(start)))
zap.Error(err))
return err
}
log.Info("close bufSink success",
zap.String("changefeed", m.changefeedID),
zap.Duration("duration", time.Since(start)))
}
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions cdc/sink/mq.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,10 @@ func (k *mqSink) EmitDDLEvent(ctx context.Context, ddl *model.DDLEvent) error {
return errors.Trace(err)
}

// Close the producer asynchronously, does not care closed successfully or not.
func (k *mqSink) Close(ctx context.Context) error {
3AceShowHand marked this conversation as resolved.
Show resolved Hide resolved
err := k.mqProducer.Close()
return errors.Trace(err)
go k.mqProducer.Close()
return nil
}

func (k *mqSink) Barrier(cxt context.Context, tableID model.TableID) error {
Expand Down