Skip to content

[Bug]: TAE metadata writers must propagate append/write errors before publishing incomplete state #29261

Open

Description

@Ariznawlll

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

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

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

66da387

Other Environment Information

  • Found by reading origin/main at 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.go doIncrementalCheckpoint) and global checkpoint (pkg/vm/engine/tae/db/checkpoint/executor.go doGlobalCheckpoint). Both collect through BaseCollector_V2.visitObject. This is not #29260 (backup rewrite ignores Write in backup.go). This is not #29259 (compact metadata WriteEnd fails and the merge returns the error). No open issue mentions visitObject or 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

  1. Run an incremental or global checkpoint whose catalog object list exceeds 16MiB, so a visitObject flush calls trySpill. DefaultCheckpointBlockRows is 10000, so this is a normal catalog, not a 512MiB single batch.
  2. Fail that spill's file-service write (object storage timeout, or an injected Sync error on the stage file sinker). Leave the checkpoint context active.
  3. Let a later flush spill successfully.
  4. Collect returns nil. CheckpointData_V2.Sync returns nil and a location. The checkpoint is saved.
  5. The location's object list is missing the rows that were in memory when trySpill failed, including rows accepted by an earlier Write that 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.visitObjectForBackup calls the same visitObject. BackupCheckpointDataFactory is only used from tests and checkpoint/testutils.go. mo_br rewrite is #29260, a different ignored Write.
  • Sinker batches for this collector are not WithOffHeap. This report does not use an mpool-cap failure. The file-service error inside trySpill is enough.
  • visitObject uses context.Background(), so checkpoint cancellation does not cancel this spill. That is separate from the short checkpoint: Sync still fails closed if its own context is already canceled.

Activity

  1. added
    kind/bug
    on Sep 22, 2026
  2. added this to the MO-202609 milestone on Sep 23, 2026
  3. added theissue type on Sep 23, 2026
  4. added
    severity/s0
    and removed on Sep 23, 2026
  5. changed the title [-][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[/+] on Oct 22, 2026
  6. changed the title [-][Bug]: Checkpoint writers must propagate sinker.Write errors before publishing output[/-] [+][Bug]: TAE metadata writers must propagate append/write errors before publishing incomplete state[/+] on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

4.3-devkind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions