Repository navigation
Description
Is there an existing issue for the same bug?
- I searched open and closed issues for the exact rewrite symbol and backup/checkpoint memory leaks.
Branch Name
main; the same missing input-batch cleanup is also present in inspected 4.2-dev source.
Commit ID
- Current main at investigation:
1876b2f93e14c03ba538e3806e245e3c3203979a. - Executed diagnostic source:
387da6a1280b13e10936896f522d4ddb15f27555, a main-based MinIO backup PR head.pkg/vm/engine/tae/logtail/backup.go,pkg/objectio/ioutil/sinker.go, andpkg/common/mpool/mpool.goare byte-identical to the main commit above. The MinIO patch does not modify the failing code. - Inspected 4.2-dev base:
10d204b8763f19b2b37ba2147d1d4c1a7828d6d4. Runtime reproduction below is on main only; 4.2 runtime verification is pending.
Other Environment Information
- Linux amd64, Go 1.27.1, GOEXPERIMENT=simd, GOAMD64=v3, repository CGo test wrapper.
- Isolated test process, 2 CPU and 6 GiB limits, 90-second Go test timeout.
- Persisted checkpoint format through MemoryFS with caches disabled; real checkpoint writer/reader/rewrite functions. No running cluster, MinIO, SQL driver, or network is needed.
Actual Behavior
ReWriteCheckpointAndBlockFromKey allocates input batches using common.CheckpointAllocator, fills them with checkpoint object metadata, and passes them to dataSinker.Write, but never cleans the input batches:
objectInfoMetaandtombstoneInfoMetain thelen(insertObjBatch) > 0branch;destin the other branch.
Sinker.Write copies with UnionWindow; it does not take ownership of its input. dataSinker.Close releases the sinker's own copies, not these original batches. The rewrite's existing objData cleanup also does not own these three locals.
MPool records these on-heap allocations in the global pointer registry keyed by unsafe.Pointer. Therefore losing the local batch variable does not make its backing allocations collectible. Explicit Batch.Clean is required. This is retained live memory, not merely a cumulative allocation counter or an RSS decay delay.
Runtime Evidence
A diagnostic invokes the actual rewrite three times on the same 32-object checkpoint, with a fresh disabled-cache destination each time. After every successful return it calls runtime.GC() and reads common.CheckpointAllocator.OnHeapOutstanding() relative to the pre-rewrite baseline.
Both branches reproduce independently:
| Iteration | Additional retained bytes | Additional retained allocations |
|---|---|---|
| 1 | 9,632 | 10 |
| 2 | 19,264 | 20 |
| 3 | 28,896 | 30 |
The two fixtures are (1) unchanged/non-rewritten object metadata and (2) nonappendable objects whose deletion timestamp is cleared by backup rewriting. Both original-source subtests fail the zero-residual-ownership assertion; all rewrite calls themselves succeed.
An isolated Go overlay adds only three deferred Clean(common.CheckpointAllocator) calls, one immediately after each batch construction. With unchanged inputs, both subtests pass and report 0 retained bytes / 0 retained allocations after all three iterations. No product branch or existing PR was changed by this diagnostic control.
Expected Behavior
The creator retains ownership of input batches passed to copying Sinker.Write. Release them on success and on all error exits. Repeated successful checkpoint rewriting must not accumulate outstanding allocations from these input batches.
Steps to Reproduce
- Create a disabled-cache MemoryFS source and a real checkpoint with 32 object metadata rows using
ckputil.NewDataSinker,appendValToBatch, andCheckpointData_V2.Sync. Clean the fixture input and close its sinker before measuring. - For the unchanged branch use create TS 20 and empty delete TS. For the nonappendable rewrite branch use create TS 5 and delete TS 30. Use backup TS 15.
- Open the checkpoint with
GetCheckpointReader. - Record
common.CheckpointAllocator.OnHeapOutstanding(). - Three times: create a new disabled-cache MemoryFS destination, call
ReWriteCheckpointAndBlockFromKey, assert success, callruntime.GC(), and record outstanding bytes/allocations. - Assert the final ownership equals the initial baseline. It fails with the increments above.
- Repeat with only the three missing input-batch cleanup calls added: residual ownership is zero.
Command used through the repository-supported CGo wrapper:
.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=90s \
-run '^TestDiagnosticBackupRewriteMemoryOwnership$' ./pkg/vm/engine/tae/logtailRoot Cause And Code References
- Input batch construction and write calls.
- Copying Sinker.Write contract.
- Global pointer ownership registry.
- Public backup reaches this function through
pkg/backup.execBackupwhen rewriting the special checkpoint.
Scope And Limits
- This is separate from [Bug]: MinIO physical backup allocates 528 MiB per unknown-length stream copy #32077 (unknown-length MinIO multipart buffers) and is independent of storage provider and copy parallelism.
- [Bug]: backup checkpoint rewrite ignores a sinker Write error and can publish a short object list #29260, consolidated into [Bug]: TAE metadata writers must propagate append/write errors before publishing incomplete state #29261, covers ignored write failures/incomplete checkpoint publication, not successful-call input-batch memory ownership. [Bug]: memory leak detected during bvt test in backup_test.go #14714 was an older test-fixture allocation issue.
- The demonstrated retained amount is for 32 metadata rows. This does not prove that this defect caused a particular production 30 GiB peak, nor does it measure large-backup growth or CN RSS.
- The three-line control establishes the cause, but is not full fix acceptance: cancellation, append/write failure, full backup/restore, and 4.2 runtime validation should precede a production patch.
- No data-loss claim, introducing-PR attribution, production modification, or merge is made by this report.
Activity