Skip to content

[Bug]: snapshot GC meta ignores off-heap append errors and persists a short protection set #29268

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

Actual Behavior

SnapshotMeta.SaveMeta and SaveTableInfo (pkg/vm/engine/tae/logtail/snapshot.go) build off-heap batches with containers.MakeVector(..., common.DebugAllocator) and ignore every vector.AppendBytes / vector.AppendFixed error. They then WriteWithoutSeqnum + WriteEnd and return size, nil.

containers.NewVector is vector.NewOffHeapVecWithType (pkg/vm/engine/tae/containers/vector.go 101–104). DebugAllocator is mpool.NewMPool("tae_debug", 0, mpool.NoFixed), so Cap() is PiB and the practical failure is GlobalCap (pkg/common/mpool/mpool.go alloc, off-heap branch). appendOneFixed returns before publishSingleAppend when extendWithBitmaps fails. AppendBytes rolls the append back when the varlena area cannot grow. The column length does not increase.

objectWriterV1.addBlock (pkg/objectio/writer.go 790–867) sets the block row count from column 0 and only Debug logs a later column whose Length() differs. It still marshals each column and WriteEnd succeeds.

checkpointCleaner.scanCheckpointsLocked (pkg/vm/engine/tae/db/gc/v3/checkpoint.go 2628–2695) treats that nil as success and records the snapshot file and the account file. Replay loads the latest of each (checkpoint.go 451–518) via ReadMeta / ReadTableInfo into a fresh SnapshotMeta.

The in-memory maps are unchanged in the process that just flushed them. The short file is what the next TN restart rebuilds from.

  1. Silent omit, SaveMeta. Column 0 is ObjectAttr_ObjectStats. If that AppendBytes fails, Batch.Length() / the block row count stay at the previous object. Rebuild (snapshot.go 1695–1763) walks only that length, so the failed mo_snapshots / PITR / ISCP object is not restored. GetSnapshot / GetPITR / GetISCP then miss the rows stored in that object. MergeTableInfo (snapshot.go 2156–2176) drops a deleted table when the rebuilt snapshot list and PITR do not refer to it, and ObjectIsSnapshotRefers (checkpoint.go 1692–1713) will not keep the user objects those rows still name.

  2. Panic on replay instead of the allocation error. If column 0 grows and a later fixed column does not, Rebuild indexes MustFixedColWithTypeCheck (insCreateTSs[i] / insTides[i]) past the short slice. RebuildTableInfo does the same with GetRawBytesAt on the PK column (snapshot.go 1600–1644). GC replay has no recover around ReadMeta / ReadTableInfo. SaveMeta / SaveTableInfo have already returned nil and the file is the one replay selects.

SaveTableInfo has the same shape. Column 0 is the account id. A failed account append omits the table row. A failed PK append after the account id grew makes RebuildTableInfo panic. A missing table id is absent from GetAllTableIDs (exec_v1.go buildTableExistenceMap) after replay.

saveSnapshot also logs a non-nil SaveTableInfo error and still returns nil (checkpoint.go 2659–2676), so a real write failure is not a failed scan. The data-loss path above does not need that: WriteEnd succeeds on the short batch.

Expected Behavior

An off-heap append failure in SaveMeta or SaveTableInfo should return that error. scanCheckpointsLocked should not record the snapshot or account file. Replay must not rebuild protection from a batch that dropped a mo_snapshots, PITR, ISCP, or table row, and it must not panic on a short column after the writer reported success.

Steps to Reproduce

Code path, not a one-shot SQL script.

  1. Let checkpoint GC run scanCheckpointsLocked with a non-empty SnapshotMeta (objects, pitr.objects, or iscp.objects, and tables).
  2. Drive GlobalCap so one AppendBytes / AppendFixed inside SaveMeta or SaveTableInfo returns MPoolCapacity. DebugAllocator is off-heap.
  3. Observe WriteEnd still return nil and saveSnapshot still record the file.
  4. Restart the TN. Replay ReadMeta / ReadTableInfo (checkpoint.go 477–518) rebuilds from that file. A failed column-0 append omits the object or table. A later-column failure panics in Rebuild / RebuildTableInfo instead of surfacing the allocation error.
  5. The next GC cycle uses the short snapshot and PITR lists. A dropped table whose snapshot row lived in the omitted object is removed by MergeTableInfo, and ObjectIsSnapshotRefers does not keep its data objects.

Additional information

Searched open issues for SaveMeta, SaveTableInfo, SnapshotMeta, DebugAllocator, and AppendFixed GC checkpoint. The hits were #29263, #29258, #29257, and an unrelated compatibility issue. None describe this writer.

prepareCNMeta in ckp_writer.go ignores the same append calls, but it is only reached from MockCheckpointV12 (db/test/db_test.go). This report is the production SaveMeta / SaveTableInfo path.

Activity

  1. added
    kind/bug
    on Sep 23, 2026
  2. added theissue type on Sep 23, 2026
  3. added this to the MO-202609 milestone on Sep 23, 2026
  4. 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/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions