Skip to content

Commit

Permalink
fix stuck detect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sdojjy committed Dec 6, 2023
1 parent 1fa2752 commit 1247e43
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 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 @@ -116,6 +118,8 @@ func New(ctx context.Context,
tableID: tableID,
tableName: tableName,
cfg: cfg,

startResolvedTs: checkpointTs,
}
return p
}
Expand Down Expand Up @@ -185,7 +189,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 @@ -276,9 +280,13 @@ 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 advanced before
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 1247e43

Please sign in to comment.