Skip to content

Commit

Permalink
cherry-pick-9174-to-release-6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
asddongmen committed Jun 13, 2023
1 parent dc8c42d commit 2b6426e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cdc/owner/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ func (c *changefeed) releaseResources(ctx cdcContext.Context) {
changefeedBarrierTsGauge.DeleteLabelValues(c.id.Namespace, c.id.ID)
c.metricsChangefeedBarrierTsGauge = nil

if c.isRemoved {
changefeedStatusGauge.DeleteLabelValues(c.id.Namespace, c.id.ID)
}
c.isReleased = true
c.initialized = false
}
Expand Down
11 changes: 10 additions & 1 deletion cdc/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,11 @@ func (p *processor) Close() error {
log.Info("processor closing ...",
zap.String("namespace", p.changefeedID.Namespace),
zap.String("changefeed", p.changefeedID.ID))

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

for _, tbl := range p.tables {
tbl.Cancel()
}
Expand Down Expand Up @@ -941,6 +946,11 @@ func (p *processor) Close() error {
}
// mark tables share the same cdcContext with its original table, don't need to cancel
failpoint.Inject("processorStopDelay", nil)

return nil
}

func (p *processor) cleanupMetrics() {
resolvedTsGauge.DeleteLabelValues(p.changefeedID.Namespace, p.changefeedID.ID)
resolvedTsLagGauge.DeleteLabelValues(p.changefeedID.Namespace, p.changefeedID.ID)
checkpointTsGauge.DeleteLabelValues(p.changefeedID.Namespace, p.changefeedID.ID)
Expand All @@ -952,7 +962,6 @@ func (p *processor) Close() error {

pipeline.SorterBatchReadSize.DeleteLabelValues(p.changefeedID.Namespace, p.changefeedID.ID)
pipeline.SorterBatchReadDuration.DeleteLabelValues(p.changefeedID.Namespace, p.changefeedID.ID)
return nil
}

// WriteDebugInfo write the debug info to Writer
Expand Down

0 comments on commit 2b6426e

Please sign in to comment.