Repository navigation
refactor(tae): replace containers.Batch with batch.BatchWithDeletes (#33337) - #33541
Conversation
Column loaders fill a *batch.Batch and set its row count; read-filter searches take []*vector.Vector. containers.Vectors is removed, and objectio no longer imports the TAE containers package for it. Batch.InitVectors allocates up to 8 vectors and their pointers at once, and the Batch stays on the caller's stack. The reader creates its scratch vectors on the first load, sized to the block: scans that copy straight to the output never allocate them. LoadColumnsDataFromMeta's release no longer moves the IOVector to the heap. The checkpoint readers no longer copy vector headers that share ownership of their buffers. VectorsCopyToBatch becomes CopyBatch; its test now checks the appends. In containers, VectorPool picks an element with math/rand/v2 instead of a linkname to runtime.cheaprand (about 3 ns per GetVector), and both runtime*.go files are removed; runtime.go was never built. Add benchmarks for tombstone reads, a reader's life, and the vector pool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
containers/mock.go holds test data generators but was part of the production package. Move it, with its test, to tae/testutils. catalog.MockBatch, a wrapper over it in a non-test file, becomes testutils.MockSchemaBatch, so no production package imports testutils. It takes an interface: testutils cannot import the catalog without import cycles. MockNullableBatch, only the body of MockBatch, is merged into it. The containers tests that use the mocks become package containers_test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The same switches moved from tae/containers/mock.go to tae/testutils/mock.go; no entry is added. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rixorigin#33337) batch.BatchWithAttr is a Batch with column names, optional column seqnums and a delete bitmap. It replaces TAE's Batch and BatchWithVersion; batch.Batch is unchanged. BatchSplitter becomes a loop over CloneWindow. Names are found by scanning Attrs up to 8 columns and through a private index above that, checked against Attrs on each lookup, so removing or reordering columns cannot make a name find another column, as the old Nameidx could. Logtail collection walks the columns in seqnum order instead of sorting the batch, which reordered a live transaction node's columns in place. VectorPool moves to pkg/container/vector, so that Close can return lent vectors. Delete, RangeDelete and CloneWindow take the pool they allocate from. The WAL codec becomes functions (WriteBatch, ReadBatch) with the same bytes; a golden test pins them to a hash computed with the old code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Queue requested — the merge queue status continues in this comment ↓. |
The type-switch baseline may only shrink: tag MockVector and MockVector2, whose default handles the remaining types, and drop their baseline entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: c1c68720cb57f8ea219be4fc6c6914c604a8f81b
Assessment: approve
The refactor consolidates TAE batch and vector-pool ownership into the shared container packages while retaining the TAE metadata and WAL encoding contracts. No actionable defects were found.
Model: gpt-6.1-terra / max
Session: 01a22b07-00b6-7e32-b0a1-3099d0b867c7 · slot 1 · generation 39
Validation:
-
Isolation preflight passed. Full batch, vector, types and TAE container tests passed, including the old-writer WAL golden hash and V2 compatibility tests: checks/1796065598097356761-3.json.
-
Full object I/O, block I/O, reader and logtail package tests passed: checks/1796065943493981330-3.json.
-
Targeted checkpoint compatibility, delete replay, schema padding, rollback and materialization tests passed: checks/1796066475517299565-3.json.
-
Batch, vector and TAE container package tests passed under the race detector: checks/1796066618542240642-3.json.
-
A two-CN SQL probe passed across schema evolution, committed and rolled-back writes, flushing and same-binary restart: checks/1796067023412549070-3.json.
-
Focused backup restore, publication filtering and merge tests passed: checks/1796067191764707896-3.json.
Limitations:
-
The checkpoint compatibility fixture uses the current binary to construct a legacy-format checkpoint; no released predecessor binary was run.
-
The author's performance measurements were not independently reproduced.
…#33337) AppendCmd.ReadFrom ignores the error of reading its batch again, and ReadWAL returns the part it could read. The comment says why that is dangerous. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
🚫 Left the queue · pull request dequeued21 min in the queue, with no time running CI. So far
Reason Pull request #33541 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
|
mo-bot review · Commit: "interrupted" |
Its squash (af2c49a) has the same tree as 1e74629, which this branch is stacked on, so this branch's tree is the merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [x] Code Refactoring ## Which issue(s) this PR fixes: issue #33337 ## What this PR does / why we need it: This follows #33541. Together its commits remove the `tae/containers` package. | Was | Now | |---|---| | `containers.MakeVector(t, mp)` | `vector.NewVec(t, mp)` | | `containers.BuildBatch(types, opts)` | `batch.NewBatchWithDeletesTypes(types, mp)` | | `containers.BuildBatchWithPool(...)` | `batch.NewBatchWithDeletesFromPool(types, rows, pool)` | | `containers.Options` | removed; `Capacity` was never set | | `containers.BatchFreeList` | `batch.FreeList` | | `containers.OneSchemaBatchBuffer` | `batch.NewFreeListWithLimit(maxBytes)` | | `containers.IBatchBuffer` | removed; the sinker holds a `*batch.FreeList` | | sinker buffer statistics | removed; they never updated | | `containers.Vector`, `VectorPool`, `ReleaseVector`, ... | the `pkg/container/vector` originals they forwarded to | | `GeneralBatchBuffer`, `Usage()`, `offHeap`, `WithOffHeap` | removed: used only by tests, or stored and never read | | `ToCNBatch(b)`, `ToTNBatch(b)` | `b.AsBatch()`, `batch.NewBatchWithDeletesOf(b)` | | `DedupSortedBatches`, `CopyBatch` | `batch.DedupSorted`, `Batch.CopyFrom` | | `UpdateValue` | `vector.UpdateAny`, or `vector.UpdateFixedAt` without boxing | | `MarkNull`, `CloneVector` | `Vector.TrySetNull`, `VectorPool.Clone` | | `ForeachWindowBytes` | `vector.ForeachRaw` | | `ForeachVector`, `ForeachVectorWindow`, `ForeachWindowFixed`, `ForeachWindowVarlen`, `MakeForeachVectorOp` | typed `vector.ForeachFixed` and `ForeachBytes`; two type switches go | | `getNonNullValue` | removed; only tests used it | For reviewers: - **Key types.** Persisted dedup (`tables/functions.go`) now takes its typed probe from its own table. `MakeForeachVectorOp` had no BIT or YEAR case and panicked on those keys, as far as the code shows; they work now, and `TestPersistedDedupKeyTypes` covers every key type in the tables. A type without a dedup function is an error, not a panic. - **Duplicate code.** The fixed-size and varlena appendable-block probes share one `aBlkMatches.visit`. - **Errors instead of panics.** `UpdateAny`, `UpdateFixedAt` and `TrySetNull` return errors, and callers pass them on. `TrySetNull` refuses a read-only vector; `MarkNull` did not check. - **Constant vectors.** `ForeachRaw` handles constant fixed-size vectors (the old code sliced past their one value), and `ForeachBytes` applies a selection to a constant, which was ignored. A nil or empty selection still means every row. - **DedupSorted.** An empty key after an empty first batch is no longer taken for a duplicate. - A nil pool used to mean TAE's default pool. `vector.NewVec` with a nil pool makes a read-only vector, so a nil now fails on the first append. Literal nils were only in tests, which now name the pool. - `NewBatchWithDeletesFromPool` returns an allocation failure as an error and gives back the vectors it borrowed; `BuildBatchWithPool` panicked. A transaction append now fails with the error. `MakeBufferBatch` has no error result and still panics. - `FreeList` reuses a kept batch only if its column type OIDs match the requested types, and then gives it those types; before, it ignored them. - `FreeList` has no mutex; `OneSchemaBatchBuffer` had one. Its users, GC and `TransferFlow`, run sequentially and do not enable the sinker's pipeline mode. - The limit works as before: a batch that would take the list over it is freed. GC and transfer limits are unchanged. - The sinker has two unexported hooks, nil outside tests, where tests that faked the interface inject failures. In `multi_update` those tests now observe deletes and memory instead; I checked that each fails when the ownership code is broken. - `UpdateAny` and `UpdateFixedAt` reject a row out of range. - **Flaky test, not from this change.** `TestIssue25590TwoDirtyObjectCompactionIsAtomicAcrossReplacements` and `...RecordFailureAfterStagedReplacementRetracts` read the ledger while the GC pool may still be deleting the rewritten originals. `main` fails too (20 of 390 stress processes). The fixed count was wrong for a worker that may be anywhere, so they now run with the worker about to delete, deleted but not settled, finished, and racing. Each order checks ownership, the recorded copy, GC claims and files on storage, which replaces the count. Settling before deleting, dropping the recorded copy first, losing the GC claim, and not deleting each fail it. 0 of 240 stress processes fail, and `-race` is clean. - **Fix: `TransferFlow.Process`.** It deferred the put-back inside its read loop, so each batch read took a new buffer, all held until the end. It now reads into one buffer, put back before the final transfer and sync. `TestTransferFlowReusesReadBuffer` counts 51 buffers for 50 batches with the old loop, 1 now. ## Testing - Unit tests on the final code: `pkg/container`, `pkg/objectio`, `pkg/vm/engine/tae`, `disttae`, `engine/test`, `pkg/publication`, `pkg/backup`, `pkg/datasync`, `pkg/vectorindex/ivfflat`, `pkg/tools`, `pkg/iscp`, and `pkg/sql/colexec` with `multi_update`. New tests for the moved functions. - Sinker write, spill and sync benchmark, 8 interleaved runs, up to the `FreeList` commit vs. the first commit: median 7.12 ms vs 7.22 ms; 593 allocs/op both. - Last commit vs. the one before: index building unchanged; persisted dedup level or faster with fewer allocations (1,038 to 13 per op at 1,024 probes), except a one-row block, about 80 ns more per block (180 to 259 ns). Sinker +2.4%, equal allocations, within its noise. - `-race` on the last commit: `container/batch`, `tae/tables`, `tae/index`, `tae/txn`, `tae/blockio`, `objectio/ioutil`. Before it: `container/batch`, `objectio/ioutil`, `readutil`, `tae/db/gc`, `multi_update`, and the transfer, tombstone, GC and sinker tests of `disttae` and `engine/test`. - Transfer fix: all of `disttae` and `engine/test`; `-race` on their transfer and tombstone tests. - `make static-check-changed` (full graph): 0 issues. - Not run locally: BVT. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #33337
What this PR does / why we need it:
batch.BatchWithDeletesembedsBatchand adds a delete bitmap. It replaces TAE'sBatchandBatchWithVersion.batch.Batchis unchanged.Attrs,NameidxandSeqnumsare gone; names and seqnums come from the schema. Fixed layouts (checkpoint, snapshot, tombstone, object metadata) are read by position, scans by the position incolIdxes.BatchWithDeletes.WriteWALandbatch.ReadWAL, which take and return the names. Replay maps them once to the object's schema, because a record may come from an older one. The unreachable V1 and V2 codecs are removed: only append command version 3 has been registered since remove stale compatibility code #21883.AppendCmd.ReadFromstill ignores the error of reading its batch, as before; a comment now says why that is dangerous.BatchSplitteris a loop overCloneWindow.VectorPoolmoves topkg/container/vector, soClosecan return lent vectors.containerskeeps thin wrappers.Delete,RangeDeleteandCloneWindowtake the mpool they allocate from.For reviewers:
AppendDataToTablerejects a CN write whose columns are not the first columns of the table, in order. Such a write used to be copied by schema position whatever its names said.RowCountis overridden; the count stored in the embeddedBatchis not maintained.Compatibility
TestWriteWALGoldenpins them to a hash computed with the oldcontainers.Batch.WriteTo.ALTER(add, drop and rename column), accounts and a snapshot.Testing
pkg/container,pkg/objectio,pkg/vm/engine,pkg/publication,pkg/backupandpkg/datasync.container/batch, TAEcontainers,logtail,txnimpl,tables,catalog, andpublication.ddl,dml,table,fake_pk,auto_increment,vector,publication_subscription.snapshotandpessimistic_transactionwere stopped by a time limit, with no failures in the files that ran.make static-check-changed(full graph): 0 issues.mainand moving the codec: unit tests ofpkg/container,pkg/objectio,pkg/vm/engine,pkg/publicationandpkg/backup, the static check, and crash recovery old to new and new to new. BVT and the race detector were not repeated.🤖 Generated with Claude Code