Repository navigation
refactor(tae): remove the containers package (#33337) - #33545
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]>
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]>
BatchWithAttr loses Attrs, Seqnums and the name index, and becomes BatchWithDeletes. Names and seqnums come from the schema. - Checkpoint, snapshot, tombstone and object metadata batches are read by the positions their schemas give; scans by the position in colIdxes. - The logtail builders return the column names next to the batch; what goes over the wire is unchanged. In-memory rows take the schema of their version. - The WAL codec takes and returns the names. Replay maps them to the object's schema once; a column the record does not have is nil. The bytes are unchanged. - A CN write must name the first columns of the table, in order. It used to copy by schema position whatever the names said. - A transaction's node keeps the schema its rows were built with, for the WAL and the logtail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rixorigin#33337) containers/batch_codec.go becomes BatchWithDeletes.WriteWAL and batch.ReadWAL, which take the mpool they allocate from. The bytes are unchanged; the golden test moves along. The V1 and V2 readers and the V2 writer are removed. Only append command version 3 has been registered since matrixorigin#21883, so nothing could reach them. What only they used goes too: bitmap.UnmarshalV1 and tae/common/bitmap.go. AppendCmd.ReadFrom returns the error of reading its batch, which it dropped, so a cut short record is no longer replayed as the part that could be read. The byte counts it and WriteTo return are now right. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#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]>
MakeVector becomes vector.NewVec; a nil pool no longer means TAE's default one. BuildBatch and BuildBatchWithPool become batch.NewBatchWithDeletesTypes and NewBatchWithDeletesFromPool, which returns an allocation failure as an error instead of panicking. Options goes: its Capacity was never set. 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? |
|
This pull request is merged. |
…rs (matrixorigin#33337) BatchFreeList becomes batch.FreeList, which hands out a kept batch only if its column types match. IBatchBuffer becomes ioutil.BatchBuffer, what the sinker calls. GeneralBatchBuffer had only its test; offHeap (WithOffHeap included) was stored and never read; Usage had no caller. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Summary by Qodorefactor(tae): remove the containers package
AI Description
Merge Risk
|
Code Review by Qodo
1. Reused batches retain wrong column types
|
…origin#33337) Get compared type ids only, so a batch could keep another width, scale or collation, or a constant column. UpdateFixedAt and UpdateAny reject a row out of range; a negative one was written but left NULL. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A completed compaction deletes the originals it rewrote on the GC pool. Two tests read the ledger right after, and failed when the worker had already retired those members. Hold the deletions, then check that they settle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Holding the worker checked one order only. The two tests now run with it about to delete, after deleting but before settling, finished, and racing, and check what must hold in each: which objects are owned, recorded, owed to a GC job and still on storage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
mo-bot review · Commit: "interrupted" |
What type of PR is this?
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/containerspackage.containers.MakeVector(t, mp)vector.NewVec(t, mp)containers.BuildBatch(types, opts)batch.NewBatchWithDeletesTypes(types, mp)containers.BuildBatchWithPool(...)batch.NewBatchWithDeletesFromPool(types, rows, pool)containers.OptionsCapacitywas never setcontainers.BatchFreeListbatch.FreeListcontainers.OneSchemaBatchBufferbatch.NewFreeListWithLimit(maxBytes)containers.IBatchBuffer*batch.FreeListcontainers.Vector,VectorPool,ReleaseVector, ...pkg/container/vectororiginals they forwarded toGeneralBatchBuffer,Usage(),offHeap,WithOffHeapToCNBatch(b),ToTNBatch(b)b.AsBatch(),batch.NewBatchWithDeletesOf(b)DedupSortedBatches,CopyBatchbatch.DedupSorted,Batch.CopyFromUpdateValuevector.UpdateAny, orvector.UpdateFixedAtwithout boxingMarkNull,CloneVectorVector.TrySetNull,VectorPool.CloneForeachWindowBytesvector.ForeachRawForeachVector,ForeachVectorWindow,ForeachWindowFixed,ForeachWindowVarlen,MakeForeachVectorOpvector.ForeachFixedandForeachBytes; two type switches gogetNonNullValueFor reviewers:
Key types. Persisted dedup (
tables/functions.go) now takes its typed probe from its own table.MakeForeachVectorOphad no BIT or YEAR case and panicked on those keys, as far as the code shows; they work now, andTestPersistedDedupKeyTypescovers 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,UpdateFixedAtandTrySetNullreturn errors, and callers pass them on.TrySetNullrefuses a read-only vector;MarkNulldid not check.Constant vectors.
ForeachRawhandles constant fixed-size vectors (the old code sliced past their one value), andForeachBytesapplies 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.NewVecwith 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.NewBatchWithDeletesFromPoolreturns an allocation failure as an error and gives back the vectors it borrowed;BuildBatchWithPoolpanicked. A transaction append now fails with the error.MakeBufferBatchhas no error result and still panics.FreeListreuses a kept batch only if its column type OIDs match the requested types, and then gives it those types; before, it ignored them.FreeListhas no mutex;OneSchemaBatchBufferhad one. Its users, GC andTransferFlow, 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_updatethose tests now observe deletes and memory instead; I checked that each fails when the ownership code is broken.UpdateAnyandUpdateFixedAtreject a row out of range.Flaky test, not from this change.
TestIssue25590TwoDirtyObjectCompactionIsAtomicAcrossReplacementsand...RecordFailureAfterStagedReplacementRetractsread the ledger while the GC pool may still be deleting the rewritten originals.mainfails 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-raceis 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.TestTransferFlowReusesReadBuffercounts 51 buffers for 50 batches with the old loop, 1 now.Testing
pkg/container,pkg/objectio,pkg/vm/engine/tae,disttae,engine/test,pkg/publication,pkg/backup,pkg/datasync,pkg/vectorindex/ivfflat,pkg/tools,pkg/iscp, andpkg/sql/colexecwithmulti_update. New tests for the moved functions.FreeListcommit vs. the first commit: median 7.12 ms vs 7.22 ms; 593 allocs/op both.-raceon 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 ofdisttaeandengine/test.disttaeandengine/test;-raceon their transfer and tombstone tests.make static-check-changed(full graph): 0 issues.🤖 Generated with Claude Code