Repository navigation
Description
Additional consolidated scope
Checkpoint and snapshot metadata persistence must not report success after an off-heap append or sinker write fails. The reports cover distinct writers but share the same fail-closed publication invariant. Related reports remain separate reproductions where they exercise distinct paths. Closing a source issue records tracking consolidation only; no fix is claimed.
Additional acceptance criteria
- Backup checkpoint rewrite propagates sinker.Write errors before Sync or publication.
- Incremental/global checkpoint collection propagates sinker.Write errors before clearing the source batch.
- SnapshotMeta.SaveMeta/SaveTableInfo propagate vector.AppendBytes/AppendFixed failures and do not persist a short protection set.
- Keep GC keep-set error rewriting and checkpoint compact cleanup failures ([Bug]: checkpoint GC clears a keep-set failure and can delete an object a live table still references #29258/[Bug]: checkpoint compact leaves new objects behind when metadata write fails after Sync #29259) separate; their failure semantics differ.
Additional reports
- #29268 — original report and discussion remain on that issue.
Consolidated tracking scope
Two checkpoint-writing paths discard sinker.Write errors and can still publish incomplete output. They are distinct call sites and failure reproductions, consolidated here because both violate the same error-propagation contract; this does not claim a single immediate code defect.
Acceptance criteria
- In backup checkpoint rewriting (
ReWriteCheckpointAndBlockFromKey), inject adataSinker.Writefailure and verify the error is returned beforeSyncor publication; no short object list is reported as success. - In incremental/global checkpoint collection (
BaseCollector_V2.visitObject), inject asinker.Writefailure and verify it propagates before the source batch is cleared; no checkpoint omits object rows while succeeding. - Keep GC keep-set deletion and checkpoint compact cleanup failures (including [Bug]: checkpoint GC clears a keep-set failure and can delete an object a live table still references #29258/[Bug]: checkpoint compact leaves new objects behind when metadata write fails after Sync #29259) as separate issues; their failure semantics differ.
Included report
- #29260 — backup checkpoint rewrite path; the original report and discussion remain on that issue.
Original canonical report (preserved verbatim)
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
Other Environment Information
- Found by reading
origin/mainat the commit above. Not reproduced with a live TN. - Hardware parameters: code inspection
- OS type: n/a
- Others: incremental checkpoint (
pkg/vm/engine/tae/db/checkpoint/ickp_exec.godoIncrementalCheckpoint) and global checkpoint (pkg/vm/engine/tae/db/checkpoint/executor.godoGlobalCheckpoint). Both collect throughBaseCollector_V2.visitObject. This is not#29260(backup rewrite ignoresWriteinbackup.go). This is not#29259(compact metadataWriteEndfails and the merge returns the error). No open issue mentionsvisitObjector this collector.
Actual Behavior
BaseCollector_V2.visitObject discards sinker.Write and then always clears the source batch:
if collector.data.batch.Size() >= collector.objectSize || collector.data.batch.RowCount() >= DefaultCheckpointBlockRows {
collector.data.sinker.Write(context.Background(), collector.data.batch)
collector.data.batch.CleanOnlyData()
}collectObjectBatch errors are returned. This Write error is not. CleanOnlyData sets the row count to 0. ForeachMVCCNodeInRange therefore returns nil, Collect returns nil, and IncrementalCheckpointDataFactory / GlobalCheckpointDataFactory hand the sinker to CheckpointData_V2.Sync.
Production factories pass size == 0. NewBaseCollector_V2 then sets the collector flush size to DefaultCheckpointSize (512MiB), but NewCheckpointData_V2 passes that same 0 into WithMemorySizeThreshold. Sinker.fillDefaults rewrites a 0 threshold to DefaultInMemoryStagedSize (16MiB). NewDataSinker also sets WithTailSizeCap(0). The collector flushes every DefaultCheckpointBlockRows (10000) rows, or at 512MiB. Those writes accumulate in the sinker until 16MiB, and pushStaged then calls trySpill.
trySpill sorts, registers defer cleanupInMemoryStaged(), then syncFileSinker. A file-service error from that spill returns from Write. The defer drops every in-memory staged batch, including rows whose earlier Write already returned nil and had not spilled yet. Earlier successful spills stay in staged.persisted. CleanOnlyData then drops the source batch, including rows Write had not copied yet. Those rows are in neither the sinker nor the collector.
visitObject keeps scanning. Later flushes can spill successfully. Sync does not remember the ignored error. It writes whatever is still in data.batch (that call checks the error), spills the tail because tailSizeCap is 0, and publishes staged.persisted. allMergeSorted and dedupAll stay false, so a partial list is appended. transferred is set. doIncrementalCheckpoint / doGlobalCheckpoint then save the checkpoint.
The published object list is missing the window cleanupInMemoryStaged dropped. It can still contain objects spilled before that window and objects collected after it. Replay and CN logtail consumers treat the checkpoint as complete, so creates or tombstones in the gap are omitted.
A canceled checkpoint context is not this case. visitObject writes with context.Background(), but CheckpointData_V2.Sync uses the checkpoint context and returns context.Cause when that context is already done. The publication defers then delete the objects Sync returned. The bug is a file-service error while the checkpoint context is still active, followed by a later spill that succeeds.
GC builds its coarse bloom from the published global checkpoint (MakeBloomfilterCoarseFilter reads globalCkpLoc). A name that was dropped is a bloom miss. The fine filter still keeps a row whose delete timestamp is empty and whose table still exists, so this report does not claim that every missing live row is deleted. The checkpoint itself is already wrong.
The table-id index path in the same file checks the error before CleanOnlyData (syncTableIDBatch, the bat.RowCount() >= BatchRowCountThreshold branch). The object collector does not.
Expected Behavior
visitObject should return the sinker.Write error and leave the source batch intact. Collect should fail, and doIncrementalCheckpoint / doGlobalCheckpoint should not publish. Objects already spilled for that attempt should be deleted by the existing deletePersistedCheckpointObjects path (transferred stays false). The same Write in CheckpointData_V2.Sync and in syncTableIDBatch already works this way.
Steps to Reproduce
- Run an incremental or global checkpoint whose catalog object list exceeds 16MiB, so a
visitObjectflush callstrySpill.DefaultCheckpointBlockRowsis 10000, so this is a normal catalog, not a 512MiB single batch. - Fail that spill's file-service write (object storage timeout, or an injected
Syncerror on the stage file sinker). Leave the checkpoint context active. - Let a later flush spill successfully.
Collectreturns nil.CheckpointData_V2.Syncreturns nil and a location. The checkpoint is saved.- The location's object list is missing the rows that were in memory when
trySpillfailed, including rows accepted by an earlierWritethat had not spilled yet. Objects spilled before and after that window are present.
No test injects a Sinker.Write error in visitObject.
Additional information
NewBackupCollector_V2.visitObjectForBackupcalls the samevisitObject.BackupCheckpointDataFactoryis only used from tests andcheckpoint/testutils.go.mo_brrewrite is#29260, a different ignoredWrite.- Sinker batches for this collector are not
WithOffHeap. This report does not use an mpool-cap failure. The file-service error insidetrySpillis enough. visitObjectusescontext.Background(), so checkpoint cancellation does not cancel this spill. That is separate from the short checkpoint:Syncstill fails closed if its own context is already canceled.
Activity
[-][Bug]: checkpoint object collector ignores sinker.Write and can publish a checkpoint that skips object rows[/-][+][Bug]: Checkpoint writers must propagate sinker.Write errors before publishing output[/+][-][Bug]: Checkpoint writers must propagate sinker.Write errors before publishing output[/-][+][Bug]: TAE metadata writers must propagate append/write errors before publishing incomplete state[/+]