Repository navigation
Description
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 SQL session. - Hardware parameters: code inspection
- OS type: n/a
- Others: cross-check of the CN multi_update S3 delete flush against the in-memory delete path
Actual Behavior
multi_update's S3 delete flush can commit a DELETE or UPDATE that omits tombstone rows, and still return success.
prepareDeleteBatches marks a row offset in the block bitmap before appending it, then discards both append errors:
// pkg/sql/colexec/multi_update/s3writer_delegate.go
bitmap.Add(uint64(rowOffset))
vector.AppendFixed(block.bat.GetVector(RowIDIdx), rowID, false, proc.GetMPool())
block.bat.GetVector(PkIdx).UnionOne(bat.GetVector(PkIdx), int64(i), proc.GetMPool())
block.bat.SetRowCount(block.bat.Vecs[0].Length())The tombstone batch is off-heap (newDeleteBatch → batch.NewOffHeap / vector.NewOffHeapVecWithType in pkg/sql/colexec/multi_update/delete.go). Off-heap growth goes through MPool.alloc / MPool.Grow, which return moerr.NewMPoolCapacityNoCtxf when GlobalCap, mp.Cap(), or the physical allocator rejects the grow (pkg/common/mpool/mpool.go). That failure does not require a ~2GiB on-heap allocation.
On that capacity error the row is not published:
AppendFixed→appendOneFixedWithSourcereturns fromextendWithBitmapsbeforepublishSingleAppend(pkg/container/vector/vector.go). Vector length stays unchanged.UnionOnereturns from the sameextendWithBitmapscheck beforesetLengthAfterExtend(vector.go). PK length stays unchanged.SetRowCountthen usesVecs[0].Length(), which does not include the failed row.- The offset is already in
bitmap, so a later row in the same block cannot retry it. prepareDeleteBatchesreturns(retBatchs, nil).
sortAndSync treats that nil error as success and uploads the short batch. flushTailAndWriteToOutput copies it into the output batch. MultiUpdate.update then calls source.Delete on that batch (pkg/sql/colexec/multi_update/multi_update.go). The statement succeeds.
If every append in a block fails, BatchSet.Push drops the empty batch (rowCount == 0 returns nil in pkg/container/batch/batch_set.go) and sortAndSyncOneTable returns immediately on len(bats) == 0. No tombstone object is written, and the error is still nil.
The in-memory delete path does the opposite: deleteOne returns the UnionOne / UnionBatch error (pkg/sql/colexec/multi_update/delete.go). Only the S3 assembly path ignores it.
A later S3 Write/Sync error can still abort the statement. The defect is the control flow that returns success with a tombstone shorter than the rows that were supposed to be deleted. Those rows stay visible.
Expected Behavior
An off-heap append or union failure while building a tombstone batch must fail the statement. The row offset must not be committed to the bitmap unless both the rowid and pk appends succeed. The tombstone handed to source.Delete must contain every non-null rowid that this statement intended to delete.
Steps to Reproduce
Code path on main @ 66da3877e9. No live cluster run.
- Run a
DELETEorUPDATEwhose plan usesMultiUpdate.update_s3(pkg/sql/colexec/multi_update/multi_update.go).flushTailAndWriteToOutputalways callssortAndSync→prepareDeleteBatches, including for small delete batches. - Force
proc.GetMPool()off-heap growth to fail whileprepareDeleteBatchesappends a committed-block row (GlobalCap/mp.Cap()/ physical allocator).newDeleteBlockDatabuilds that batch withNewOffHeap. - Observe
prepareDeleteBatchesreturn nil afterbitmap.Add, withVecs[0].Length()unchanged for the failed row. - Observe
source.Deletereceive the shorter batch (or no batch, if every append failed andBatchSet.Pushdropped it) and the statement return success. - Read the target rows back. Rows whose append failed are still visible.
Additional information
- If the rowid
AppendFixedsucceeds and only the pkUnionOnefails,SetRowCount(Vecs[0].Length())counts a row the pk vector does not contain. That mismatch can panic later or write a bad pk. The proven silent case is both appends failing inextendWithBitmaps, which leaves both lengths unchanged. - Not the same as
#25204. That issue is workspaceSize accounting plus asyncfs.Deletelogging for objects that already enteredtxn.writes. This bug never fails the statement, so rollback GC is not involved. - Not the in-memory
collectBatchInfopath underpkg/sql/colexec/deletion, which builds an on-heap batch. This report is only the off-heap S3 tombstone assembly inmulti_update.
Activity
fix(multi_update): abort incomplete S3 tombstones (#29343)
Ariznawlll commentedon Sep 27, 2026
测试版本
main5be6cd90b501da225be591ffffe6000bf01f515e原问题验证
该问题依赖内部 reader 生命周期或 I/O 故障注入,公开 SQL 无法稳定制造目标失败点。已在最新 main 上运行对应定向测试
TestPrepareDeleteBatchesAppendFailure,连续 3 次通过。Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
确认修复提交
6397d6bc29f28f00407d44ed450eb1c87fe686a8是当前 main 的祖先,并直接执行该提交新增的定向测试,结果 3/3 PASS。回归测试
回归已落在 MatrixOne UT:
TestPrepareDeleteBatchesAppendFailure。未加入 MOTR,因为该场景必须注入内部 reader/I/O 失败,SQL 黑盒无法可靠触发;按覆盖矩阵应保留在 UT 层。测试证据
5be6cd90b501da225be591ffffe6000bf01f515e6397d6bc29f28f00407d44ed450eb1c87fe686a8测试结论
测试通过。