Skip to content

Commit

Permalink
puller(ticdc): fix stuck detect issue (#10258) (#10260)
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 a4df11e commit be9ee49
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 @@ -76,6 +76,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 @@ -117,6 +119,8 @@ func New(ctx context.Context,
tableID: tableID,
tableName: tableName,
cfg: cfg,

startResolvedTs: checkpointTs,
}
return p
}
Expand Down Expand Up @@ -184,7 +188,7 @@ func (p *pullerImpl) Run(ctx context.Context) error {
case <-ctx.Done():
return errors.Trace(ctx.Err())
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 @@ -247,9 +251,15 @@ func (p *pullerImpl) Run(ctx context.Context) error {
return g.Wait()
}

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 be9ee49

Please sign in to comment.