Skip to content

[Bug]: v12 checkpoint reader drops append errors and can omit objects or panic #29263

Closed

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

compatibilityForV12 (pkg/vm/engine/tae/logtail/ckp_reader.go 583–639) appends every converted v12 object row and ignores the error from each call:

  • vector.AppendMultiFixed for account and object type
  • Vector.Union for db, table, object stats, create ts, delete ts
  • vector.AppendFixed for the physical row id
  • vector.AppendBytes for the cluster key

It then does ckpData.SetRowCount(ckpData.Vecs[0].Length()) and returns nil. The named err is never assigned. ckpObjectReaderForV12.Read (151–201) treats that nil as success, advances objectIndex, and continues. ReadMeta installs this reader when version <= CheckpointVersion12 (289–311).

The destination batch is off-heap: ckputil.MakeDataScanTableIDBatch is batch.NewWithSchema(true, ...) (pkg/vm/engine/ckputil/data.go 38–43). appendMultiFixed updates length only after extendWithBitmaps succeeds (pkg/container/vector/vector.go 9856–9871). Union of the object-stats column (T_char, non-inline; ObjectStats is [ObjectStatsLen]byte) updates length in unionT before pregrowVarlenaArea (vector.go 8368–8439). MPool.Grow on an off-heap vector returns moerr.NewMPoolCapacityNoCtxf when the peak exceeds GlobalCap or mp.Cap.

common.CheckpointAllocator is mpool.NewMPool("tae_checkpoint", 0, ...), so Cap() is PiB and the practical failure is GlobalCap. GC and checkpoint replay both pass that pool.

Two outcomes, both after the reader has already returned success:

  1. Silent omit. If the account AppendMultiFixed fails, column 0 does not grow. Later columns that also fail before setLengthAfterExtend stay the same length. SetRowCount publishes the old length. ForEachRow (642–690) iterates only RowCount(), so the failed block's objects are never visited and nothing panics. BuildBloomfilter (pkg/vm/engine/tae/db/gc/v3/executor.go 55–77) only stops when LoadBatchData returns an error. MakeBloomfilterCoarseFilter (exec_v1.go 249–331) therefore builds a bloom without those object names. bf.Test treats a miss as absent, and an object whose create and drop timestamps are both < the GC watermark is marked for deletion. The same short batch is what checkpoint replay reads (pkg/vm/engine/tae/db/checkpoint/replay.go 656–693) and what backup opens (pkg/vm/engine/tae/logtail/backup.go 411).

  2. Panic instead of the allocation error. If column 0 grows and the object-stats Union does not, ForEachRow indexes a shorter vector (GetBytesAt at vector.go 3797–3803) or converts a short payload with objectio.ObjectStats(...). That conversion is a slice-to-array conversion of [ObjectStatsLen]byte and panics when the slice is shorter than ObjectStatsLen. A zero varlena is inline and yields a 0-byte slice (pkg/container/types/bytes.go 49–53 and 107–113). GC (pkg/vm/engine/tae/db/gc) and checkpoint replay have no recover around this read. unionT can also leave the new object-stats slots logically published when pregrowVarlenaArea fails after setLengthAfterExtend; MPool.Grow copies the old prefix and does not clear the tail (mpool.go 1376–1425, off-heap alloc uses simpleCAllocator().Allocate). A leftover header that is not a short inline value makes GetByteSlice slice area and typically panics.

ConsumeCheckpointWithTableID for version <= 12 (700–742) uses the same Read result.

Expected Behavior

An off-heap append or union failure in compatibilityForV12 should return that error. ckpObjectReaderForV12.Read, GC bloom construction, checkpoint replay, and backup should fail the operation. A failed block must not be omitted from a successful scan, and it must not be turned into a panic after the reader has reported success.

Steps to Reproduce

Code path, not a one-shot SQL script. The reader is selected only when the stored checkpoint version is <= 12.

  1. On a TN whose global checkpoint entry is still version 12, or while replaying version-12 entries at or after maxGlobalEnd.
  2. Drive GlobalCap so an off-heap grow inside compatibilityForV12 fails. Checkpoint GC uses CheckpointAllocator via NewCheckpointCleaner (pkg/vm/engine/tae/db/gc/v3/checkpoint.go 285) and ExecuteGlobalCheckpointBasedGC (window.go 143–158). Replay uses the same allocator (replay.go 255).
  3. If the account column does not grow, GC's coarse bloom misses the block's objects and MakeBloomfilterCoarseFilter marks old-enough objects for deletion while Execute still returns nil. If column 0 grew and object stats did not, ForEachRow panics and the TN crashes instead of returning MPoolCapacity.

Additional information

compatibilityFn is a closure that cannot see the named return err, and none of the append calls assign it. The current-version object reader is a different path and is not this bug.

Activity

  1. added
    kind/bug
    on Sep 22, 2026
  2. added theissue type on Sep 23, 2026
  3. added this to the MO-202609 milestone on Sep 23, 2026
  4. added a commit that references this issue on Oct 19, 2026
    d0e7f9a
  5. jiangxinmeng1 commented on Oct 21, 2026

    @jiangxinmeng1
    Contributor

    fixed by #29685

  6. Ariznawlll commented on Oct 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:官方 main
    • commit:3a1e42b4308bd0098e055ddb9360a07f85201d9c
    • 修复:#29685,MERGED,merge commit d0e7f9a552f90b28dd37c87a30c4c6dc83ae7423 已确认是本次官方 main 的祖先。
    • 部署方式:隔离的 macOS arm64 Go/race 组件测试,真实 v12 双 block checkpoint object + 容量受限 off-heap MPool/MemoryFS;此问题的触发点是内部 reader 分配失败,不是 SQL 可直接注入的路径。
    • 测试日期:2026-10-21。

    原问题验证

    在最新 main 上运行 pkg/vm/engine/tae/logtail 定向 go test -race -count=3。原报告要求的 v12 转换过程中 append/union 内存失败,现在 8 档剩余容量(1/2/4/8/16/32/64/128 字节)均返回 ErrMPoolCapacity,RowCount()=0,没有把失败当作成功发布,也没有 panic;3 轮全部通过。含真实两 block v12 对象的数据块和 tombstone 块,在首块转换失败后均返回容量错误,释放已加载块与目标 batch,CurrNB()=0;同一 reader 清理后重试成功并读回 2 行,数据/墓碑两路径各 3/3。

    Happy Path 覆盖

    1. 无容量限制的原 v12 转换成功,数据+tombstone 共 2 行;3/3。
    2. 双 block reader 失败后同实例重试成功,RowCount()=2 且最终 CurrNB()=0;数据和 tombstone 各 3/3。
    3. checkpoint table-ID 迭代正常路径与 GC/snapshot 正常控制由同组回归覆盖;未发现错误后残留的可见成功结果。

    Unhappy Path 覆盖

    1. off-heap MPool 容量不足的 8 个边界均传播容量错误,目标行数保持 0,3/3。
    2. 数据及 tombstone 双 block 中途转换失败均释放所有已加载块,随后重试不漏行、不泄漏,3/3。
    3. checkpoint 迭代、snapshot 在第 0/1/2/3 个 checkpoint 注入 reader 错误时传播原错误;GC 扫描 reader 错误和先 spill 再读错的清理/回滚定向测试在 -race -count=3 下通过。

    白盒验证

    pkg/vm/engine/tae/logtail 的 TestCompatibilityForV12PropagatesAppendError、TestCompatibilityForV12PropagatesEveryAppendError、TestCKPObjectReaderForV12ReleasesAllLoadedBlocksOnConversionError、TestConsumeCheckpointWithTableIDPropagatesIteratorError、TestSnapshotMetaPropagatesCheckpointReaderErrors:go test -race -count=3 PASS。pkg/vm/engine/tae/db/gc/v3 的 reader-error、先 spill 后 reader-error 清理和 snapshot rollback 定向组:go test -race -count=3 PASS。备份 sinker 写错误清理定向测试也 -race -count=3 PASS。这里是内部-only 内存故障注入,公开 SQL 无法确定性触发,因此不新增重复 MOTR。

    回归测试

    测试证据

    可复核的完整 main SHA、原始失败注入及正向对照断言见上述固定 commit 的测试源文件;本轮隔离本地三次 go test -race 输出均以 ok 结束,未出现 race 报告。修复 PR 的最终 review 亦记录对转换、GC、备份及清理路径的回归审查。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions