Skip to content

Commit 2e79ea7

Browse files
committed
fix(cdc): mark truncated table escalated to skip redundant UPDATE tracking
markTableTruncated already leaves every leaf dirty, which is exactly the adaptive drain's escalated state. Record it in the escalator so UPDATEs landing on a re-populated table later in the same bounded drain skip per-PK tracking instead of re-running the threshold count and a redundant mark-all-dirty. Guarded by esc != nil (nil in continuous mode); INSERT/DELETE split-merge tracking is unaffected.
1 parent 774645d commit 2e79ea7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/infra/cdc/listen.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ func processReplicationStream(ctx context.Context, nodeInfo map[string]any, cont
382382
return fmt.Errorf("failed to mark all leaves dirty for truncated table %s.%s: %w", rel.Namespace, rel.RelationName, err)
383383
}
384384
purgeTableChanges(txChanges, rel.Namespace, rel.RelationName)
385+
// All leaves are now dirty, which is the escalated state, so record it:
386+
// later UPDATEs on a re-populated table skip per-PK tracking rather than
387+
// re-running the threshold count and a redundant mark-all.
388+
if esc != nil {
389+
esc.markEscalated(rel.Namespace, rel.RelationName)
390+
}
385391
logger.Info("TRUNCATE decoded for %s.%s: marked all %d blocks dirty for rehash on next tree update", rel.Namespace, rel.RelationName, marked)
386392
return nil
387393
}

0 commit comments

Comments
 (0)