Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#9174
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
asddongmen authored and ti-chi-bot committed Jun 12, 2023
1 parent 1e2f277 commit 7653c63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cdc/owner/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,10 @@ func (c *changefeed) cleanupMetrics() {

changefeedBarrierTsGauge.DeleteLabelValues(c.id.Namespace, c.id.ID)
c.metricsChangefeedBarrierTsGauge = nil

if c.isRemoved {
changefeedStatusGauge.DeleteLabelValues(c.id.Namespace, c.id.ID)
}
}

// cleanup redo logs if changefeed is removed and redo log is enabled
Expand Down
20 changes: 19 additions & 1 deletion cdc/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,7 @@ func (p *processor) Close(ctx cdcContext.Context) error {
log.Info("processor closing ...",
zap.String("namespace", p.changefeedID.Namespace),
zap.String("changefeed", p.changefeedID.ID))
<<<<<<< HEAD
p.cancel()
if p.pullBasedSinking {
if p.sinkManager != nil {
Expand Down Expand Up @@ -1293,6 +1294,24 @@ func (p *processor) Close(ctx cdcContext.Context) error {
return errors.Trace(err)
}
log.Info("processor close sink success",
=======

// clean up metrics first to avoid some metrics are not cleaned up
// when error occurs during closing the processor
p.cleanupMetrics()

p.sinkManager.stop()
p.sinkManager.r = nil
p.sourceManager.stop()
p.sourceManager.r = nil
p.redo.stop()
p.mg.stop()
p.ddlHandler.stop()

if p.globalVars != nil && p.globalVars.SortEngineFactory != nil {
if err := p.globalVars.SortEngineFactory.Drop(p.changefeedID); err != nil {
log.Error("Processor drop event sort engine fail",
>>>>>>> a6939c3156 (changefeed (ticdc): remove status of a changefeed after it is removed (#9174))
zap.String("namespace", p.changefeedID.Namespace),
zap.String("changefeed", p.changefeedID.ID),
zap.Duration("duration", time.Since(start)))
Expand Down Expand Up @@ -1326,7 +1345,6 @@ func (p *processor) Close(ctx cdcContext.Context) error {
// mark tables share the same cdcContext with its original table, don't need to cancel
failpoint.Inject("processorStopDelay", nil)

p.cleanupMetrics()
log.Info("processor closed",
zap.String("namespace", p.changefeedID.Namespace),
zap.String("changefeed", p.changefeedID.ID))
Expand Down

0 comments on commit 7653c63

Please sign in to comment.