Skip to content

Commit

Permalink
puller(ticdc): fix stuck detect issue (#10258) (#10259)
Browse files Browse the repository at this point in the history
close #10256
  • Loading branch information
ti-chi-bot authored Dec 6, 2023
1 parent 067bb80 commit e29f81d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cdc/puller/puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ type pullerImpl struct {
cfg *config.ServerConfig
lastForwardTime time.Time
lastForwardResolvedTs uint64
// startResolvedTs is the resolvedTs when puller is initialized
startResolvedTs uint64
}

// New create a new Puller fetch event start from checkpointTs and put into buf.
Expand Down Expand Up @@ -126,6 +128,8 @@ func New(ctx context.Context,
tableID: tableID,
tableName: tableName,
cfg: cfg,

startResolvedTs: checkpointTs,
}
return p
}
Expand Down Expand Up @@ -213,7 +217,7 @@ func (p *pullerImpl) Run(ctx context.Context) error {
metricOutputChanSize.Observe(float64(len(p.outputCh)))
metricPullerResolvedTs.Set(float64(oracle.ExtractPhysical(atomic.LoadUint64(&p.resolvedTs))))
case <-stuckDetectorTicker.C:
if err := p.detectResolvedTsStuck(initialized); err != nil {
if err := p.detectResolvedTsStuck(); err != nil {
return errors.Trace(err)
}
continue
Expand Down Expand Up @@ -280,9 +284,15 @@ func (p *pullerImpl) GetResolvedTs() uint64 {
return atomic.LoadUint64(&p.resolvedTs)
}

func (p *pullerImpl) detectResolvedTsStuck(initialized bool) error {
if p.cfg.Debug.Puller.EnableResolvedTsStuckDetection && initialized {
func (p *pullerImpl) detectResolvedTsStuck() error {
if p.cfg.Debug.Puller.EnableResolvedTsStuckDetection {
resolvedTs := p.tsTracker.Frontier()
// check if the resolvedTs is advancing,
// If the resolvedTs in Frontier is less than startResolvedTs, it means that the incremental scan has
// not complete yet. We need to make no decision in this scenario.
if resolvedTs <= p.startResolvedTs {
return nil
}
if resolvedTs == p.lastForwardResolvedTs {
log.Warn("ResolvedTs stuck detected in puller",
zap.String("namespace", p.changefeed.Namespace),
Expand Down

0 comments on commit e29f81d

Please sign in to comment.