Skip to content

Commit 91c1f4d

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 91c1f4d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

internal/infra/cdc/listen.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,15 @@ 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+
// Every leaf is now dirty, which is exactly the escalated state: the
386+
// next tree update rehashes the whole table from live data. Record it
387+
// so any UPDATEs that land on the (re-populated) table later in this
388+
// bounded drain skip per-PK tracking instead of re-running the
389+
// threshold count and a redundant mark-all. esc is nil in continuous
390+
// mode; INSERT/DELETE tracking is unaffected either way.
391+
if esc != nil {
392+
esc.markEscalated(rel.Namespace, rel.RelationName)
393+
}
385394
logger.Info("TRUNCATE decoded for %s.%s: marked all %d blocks dirty for rehash on next tree update", rel.Namespace, rel.RelationName, marked)
386395
return nil
387396
}

0 commit comments

Comments
 (0)