Skip to content

[Bug]: backup checkpoint rewrite ignores a sinker Write error and can publish a short object list #29260

Closed as not planned

Description

@Ariznawlll

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 backup.
  • Hardware parameters: code inspection
  • OS type: n/a
  • Others: mo_br checkpoint rewrite (pkg/vm/engine/tae/logtail/backup.go, called from pkg/backup/tae.go). This is not #28473 (backup fails with 20405 because a source object is already missing). This path returns success. It is not #29259 (compact metadata write fails and the merge returns the error).

Actual Behavior

ReWriteCheckpointAndBlockFromKey ignores every dataSinker.Write error, then calls Sync and returns that location as a successful rewrite.

dataSinker := ckputil.NewDataSinker(
    common.CheckpointAllocator, dstFs, ioutil.WithMemorySizeThreshold(DefaultCheckpointSize))
// ...
dataSinker.Write(ctx, objectInfoMeta)
dataSinker.Write(ctx, tombstoneInfoMeta)
// else branch:
dataSinker.Write(ctx, dest)

newData := NewCheckpointDataWithSinker(dataSinker, common.CheckpointAllocator)
location, checkpointFiles, err := newData.Sync(ctx, dstFs)
if err != nil {
    return nil, nil, nil, err
}
files = append(files, checkpointFiles...)
files = append(files, location.Name().String())
return location, location, files, nil

DefaultCheckpointSize is 512MiB (pkg/vm/engine/tae/logtail/utils.go). NewDataSinker also sets WithTailSizeCap(0).

Sinker.Write copies rows and calls pushStaged. Once staged bytes reach 512MiB, pushStaged calls trySpill. trySpill sorts, then defer cleanupInMemoryStaged(), then syncFileSinker. On a file-service error, syncFileSinker returns that error, the defer drops the in-memory batch, and Write returns the error. Earlier successful spills stay in staged.persisted.

The caller discards that error. Sinker.Sync does not remember it:

  • If staged.persisted and staged.inMemory are both empty, Sync returns nil immediately.
  • If an earlier spill succeeded and memory was cleared, Sync appends those persisted stats and returns nil. allMergeSorted and dedupAll stay false for NewDataSinker, so it does not reject a partial object list.

CheckpointData_V2.Sync then builds a table-range object. CollectTableRanges returns nil when the object list is empty, and the range writer is still synced. transferred is set and the function returns a location with no error.

pkg/backup/tae.go only checks the rewrite error after consuming checkpointFiles. A nil error continues into checkpoint.MergeCkpMeta and saveTaeFilesList. The backup is stored as complete.

Rows that never reached a successful spill are absent from that checkpoint. A list that fails on its first spill becomes an empty object list. A list that fails after one successful spill keeps only the prefix, so the tombstone half can be missing while the data half is published. Restore reads this checkpoint as the set of live objects.

A canceled context is not this case. Sinker.Sync returns context.Cause when ctx is already done, and the rewrite returns that error.

Expected Behavior

A dataSinker.Write error should fail the rewrite. The objects already spilled for this attempt should be deleted, and MergeCkpMeta / saveTaeFilesList should not run. The same failure inside Sync already returns an error and deletePersistedCheckpointObjects runs because transferred is still false. The Write call before Sync needs to surface that error.

Steps to Reproduce

  1. Rewrite a checkpoint whose object-list batch reaches DefaultCheckpointSize (512MiB), so Sinker.Write calls trySpill.
  2. Fail that spill's file-service write (destination full, or an injected Sync error on the stage file sinker). Leave the context active.
  3. ReWriteCheckpointAndBlockFromKey returns a nil error and a location.
  4. The location's object list is empty, or only the prefix that spilled before the error. pkg/backup/tae.go merges that location into the backup meta and saves the file list.
  5. Restore from that backup does not see the object-list rows that were discarded by cleanupInMemoryStaged.

No test injects a Sinker.Write error in ReWriteCheckpointAndBlockFromKey.

Additional information

  • appendValToBatch also returns an error that initCkpBatch ignores. Those batches are on-heap (NewObjectListBatch uses NewWithSchema(false, ...)), so this report does not claim an mpool-cap failure there. The file-service error from trySpill is sufficient.
  • There is no defer dataSinker.Close() and no DeletePersisted around the ignored Write. A failed syncFileSinker may also leave its ActiveObjectName in staged.unpublished with no cleanup. The wrong result is the successful short checkpoint, not that name by itself.

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. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    This report is now tracked together with #29261. The canonical issue retains explicit acceptance cases for the behavior described here. This is an administrative duplicate/consolidation closure only; the underlying defect is not claimed fixed. The original description and discussion remain available on this issue.

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