Repository navigation
refactor(storage): move block file ownership to Rust storage-io - #2796
Merged
Merged
Conversation
Use the Rust slot inventory to assign and recover block identities so an old request cannot acquire a lease on reused storage. Pass the identity across CXX and register recovery batches while allocation is disabled. Verified with 159 storage-io tests with CXX enabled, a mutation that removes the generation check, a SeekDB Bazel build, and the row-key and fork-merge mysqltest cases.
Read the entry and its type before choosing the decoder so linked Tablet metadata can enumerate its shared blocks and chain blocks during recovery. Verified fork_table_merge on Linux x86-64 with the linked threshold reduced in disposable copies of both binaries. The baseline hit iterator failures and retried. The fixed binary passed on its first attempt and logged successful traversal of linked inventories.
Consolidate the identical macro block and storage object handles, use the shared request types, and remove unused manager forwarders and DDL replay request preparation. Verified the SeekDB Bazel build and checked that the deleted classes and request types have no source references.
Retain allocation, recovered and published block groups in the Rust inventory. Keep the durable Tablet group through local-store commit and let old readers share their exact version. Retire blocks only after ownership and physical I/O have ended. Remove the C++ reference hash table and reverse Tablet reclamation scan. Verified the Linux x86-64 SeekDB Bazel build and 162 storage-io tests. Row-key, fork merge and fork snapshot with an old reader passed. A 12000-row MINI and MAJOR workload retained its checksum after SIGKILL and restart.
Route C++ callers through the block manager and the owning I/O handle. Transfer the Rust hold with each read and allocation in the same CXX call, and use one owning handle for a DDL block and its redo callback. Delete the data and metadata allocation modes that selected identical behavior. Verified the SeekDB Bazel build, storage-io CXX compilation and SQL row-key and old-snapshot fork cases with the narrowed I/O bridge.
Share the allocating or reading hold with linked blocks, metadata writers, merge results and same-version Tablet copies. Acquire standalone SSTable blocks in one batch. Drop blocks through those owners and remove the remaining hand-paired C++ reference counters and bridge methods. Verified the Linux x86-64 SeekDB Bazel build and storage-io tests with CXX enabled. Real SQL exercised fork compaction, restart checksum, direct-load redo and rereading 127 washed Tablets.
Allocation can recycle a queued slot as soon as its last I/O lease retires. Include these slots in admission so a full file can accept work before the maintenance task runs. Slots with a live lease remain excluded. The branch removes ObObjectManager, ObMacroBlockHandle, the C++ reference map and its runtime Tablet scan. It also removes the data/meta allocation switch and the manual reference pairs from staged writes, linked readers, merge results, standalone SSTables and DDL redo. BlockFile assigns identities, holds block groups, leases regions, and reclaims slots. The CXX request and group travel together to data-file readers. The block manager retains configuration, I/O adaptation and physical inspection. Shared macro block code retains occupancy accounting and SSTable rebuild policy. Tablet code enumerates metadata and shares each version's group through cold loads and old readers. StorageMetaService retains the new group before data sync and local-store commit, replaces the durable root on success, and aborts on an uncertain commit. In-memory CAS publishes the new Tablet after the durable commit. Verified on Linux x86-64. The CXX-enabled storage-io suite passed 162 tests. Removing retired slots from admission makes the fixed-capacity ownership test fail. Removing the generation check makes the reuse test fail. Process validation covered MINI and MAJOR compaction and restart checksums, a fixed 32 MiB data file and growth to 86 MiB, 127 evicted Tablets, shared linked metadata, fork with an old reader, DDL macro redo, and four SSTables copied to a standby with redo and standby restart. An injected EIO after syncing the local-store root caused SIGABRT and recovery restored all 2,000 expected rows. The downstream marker check passed locally with the existing data-count assertion. Five alternating baseline and candidate runs with 30,000 rows on Linux x86-64 used a common 86 MiB data file size and matched SQL checksums. The mainline baseline was 24d0abb and the measured candidate was 42d0a8d before the admission adjustment. Median ingestion was 8.344 s and 8.339 s, warm checksum scan 38.5 ms and 33.3 ms, MINI completion 1.329 s and 0.915 s, and process RSS 339.3 MiB and 337.0 MiB. Ranges overlap. Compaction wrote about 60.3 MiB on both. The dense Rust slot is 40 bytes, up from 16, with the C++ hash table removed. Raw results and ranges are in .audit/final-bench/summary.tsv.
Stop proactive background reads and drop the scan parameter, bridge API, and per-block write timestamps. Keep demand-read verification and I/O error reporting, and preserve existing statistics module IDs. Verified the diff with git diff --check and checked that the removed scan symbols have no remaining callers.
Remove the 30-second block-file worker and its growth threshold. Allocation still reclaims eligible retired blocks before extending a full file. Verified source cleanup with git diff --check and removed the test specific to the deleted timer policy.
Open and close the Rust file in Observer, pass the owner to metadata recovery, and move read and write conversion into the existing object handle. Geometry-only callers use the product format constant while legacy consumers are migrated. Checked the diff and audited Observer and recovery call sites. The full runtime build is tracked in .audit/block-owner-build.log.
Expose explicit handle operations for allocation, read, write and holds. Record passive I/O failures with the owning file. Inject file access into log streams, recovery, calibration and garbage collection. Verified CXX-enabled storage-io tests with two test threads and checked the diff. The remaining storage and diagnostic consumers will be switched separately.
Pass the Observer-owned Rust file to configuration reload, resource reporting and virtual-table construction. Use one stats snapshot per disk row, preserve the marker fields and route the macro inspection read to its supplied file. Verified git diff --check and audited both persistent and per-query virtual table factory construction. Integrated compilation uses the explicit storage handle and bad-block diagnostics APIs.
Carry the Observer-owned Rust reference through object and linked-block I/O. Supply it from module initialization for local metadata and the shared writer. Reuse the shared writer allocation hold for writes on that block. Verified the changed call sites and git diff --check. The integrated build verifies the new signatures.
Initialize the local metadata readers and shared macro block writer with the owning file. Carry its Rust handle through packed block reads, writes, and free-space checks. Verified git diff --check and the removal of singleton calls from the shared macro-block writer.
Use the restore host for pre-copy admission and the target log stream for SSTable writes. Bind the file at Bloom scheduling so copies retain the same file and block identity. Checked the diff and traced the bootstrap, copy task and deduplicated queue call sites; final runtime validation follows integration.
Drop the obsolete geometry copy and describe the operation as opening the block file in startup logs. Audited all references to the previous storage environment field and checked the diff.
Bind tablet allocations and SSTable construction to the observer-owned file. Preserve the dependency through metadata deserialization, cache fills, deep copies, and fallback or prefetched reads so those paths can leave the global manager. Verified the scoped diff with git diff --check; full build and storage regressions require the matching blockstore and index changes.
Use the tablet-scoped reference in macro and index writers, packed SSTable reconstruction, compaction, fork, DDL writes and replay. Pass it through root and linked metadata decoding without global resolution. Verified git diff --check and traced the changed descriptors and specialized read/write entry points. Integrated production compilation and SQL verification are pending.
Require the composed Rust file on remaining I/O and hold operations. Remove the compatibility overloads, old startup binding and build inputs while keeping normal-read checks and file-scoped I/O diagnostics. Verified diff syntax and checked for remaining references to the former singleton, source and header.
Use the owning metadata pool when constructing an external tablet before its pointer has been attached. Include the I/O bridge explicitly where block status is translated. Verified the scoped diff with git diff --check.
Keep write-completion verification declared after removing the old block manager header. Verified git diff --check.
Route source-side copy reads to the file bound to the SSTable. Confirmed that standby no longer calls the removed unbound overload.
Initialize and reuse the tablet macro iterator with the same observer-owned file during publication, recovery, and cold loads. Long manifests use the linked-block reader. Verified the scoped diff with git diff --check and enumerated both initializer call sites.
The tablet creator now accesses the injected metadata pool and needs its class definition. The normal build diagnosed the missing include. Verified the scoped diff with git diff --check.
The deleted manager header used to supply the request types indirectly. Include the read and write request definitions in the translation units that construct them. Observed missing type declarations in the integrated C++ build and verified git diff --check.
The fork context wrapper now forwards the caller-provided file into the allocator-protected SSTable factory. Corrected the missing argument observed in the integrated C++ build and checked the three production call sites.
Log the existing error code explicitly and use the mutable CXX string accessor for the data path. Both fixes address the integrated Linux compile diagnostics. Verified git diff --check; rerunning the executable build.
Share submission between the validated write entry points so the request is checked once and the allocation path rejects invalid requests before allocating. Keep block-file open and its startup reporting in one Observer function. Checked all write call sites and the startup log and error paths with git diff --check; verify the committed executable through focused SQL and recovery runs.
The scanner stores sstable_ only after initialization succeeds. Pass the block file from the SSTable argument when prefetching lower levels during initialization to avoid dereferencing the unset member. Verified with a local seekdb build and the downstream query_with_major, fts_refresh_table, and sst_endkey_merge_heap cases.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Master removes the unused major and incremental range splitters. Drop the obsolete block-size changes in those implementations and keep explicit block-file propagation for the multi-range splitter that remains in use. Verified the staged diff and checked that the retired splitters have no remaining declarations or callers.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c786ba584c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
hnwyllmm
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ObBlockManager单例。storage-io,待块引用和在途 I/O 都结束后回收块槽。