Repository navigation
Conversation
Serial committed gets of the u64::MAX last shard stall unique-slot (and unique-account) persist and incremental index stages. Share one two-phase plan so RocksDB last-shard reads overlap, then serially put into a batch opened only after those gets join.
The two-phase loader still groups ETL rows under a distinct message, then emits the original Writing indices progress while serially putting shards.
Chunk history collection and preparation so large rebuilds remain restartable without exhausting memory.
Last-shard gets read committed state and must join before the write batch; an open batch does not deadlock Gets. A logical key whose ETL rows exceed the prepare byte cap still occupies one batch.
|
cyclops audit fast |
tempoxyz-bot
left a comment
There was a problem hiding this comment.
👁️ Cyclops Review
This change's read-before-write design is sound, but three actionable issues remain in chunked restart healing, zero-target pruning, and the public batch helper API.
Reviewer Callouts
- ⚡ MDBX initial-sync performance: After the first chunk, each subsequent chunk performs serial committed last-shard reads for every touched key. Benchmark a from-genesis MDBX sync, not only
--fullrestore. - ⚡ History preparation memory bound:
history_group_bytesand the projected-size calculation useVec::capacity()differently, making the 256 MiB limit soft. - ⚡ Prune clear branch:
target_reached() && prune_target_appliedis currently unreachable because history retains 10,064 blocks, but it clears the entire table if that invariant changes. Document or assert the dependency.
| if initial_sync && input.target() == 0 { | ||
| BlockRangeOutput { block_range: 0..=0, is_final_range: true } | ||
| } else { | ||
| input.next_block_range_with_threshold(self.commit_threshold.max(1)) |
There was a problem hiding this comment.
Persisting each bounded chunk creates durable states where 0 < checkpoint < static_file_tip. On restart, the unchanged RocksDB healer bypasses its checkpoint == 0 fast path and scans every remaining account changeset with per-key unwind work; the storage stage has the same issue at index_storage_history.rs:133. Large initial syncs can therefore incur hours of no-op startup healing after every interruption.
Recommended Fix:
Persist a RocksDB history-index watermark with each flush and early-return when it matches the MDBX checkpoint, or make the RocksDB write and stage checkpoint one recovery unit so healing is bounded to one chunk.
| .flatten() && | ||
| target_prunable_block > input.checkpoint().block_number | ||
| (target_prunable_block > input.checkpoint().block_number || | ||
| target_prunable_block == 0 && input.checkpoint().block_number == 0) |
There was a problem hiding this comment.
Before(0) is treated as pruning genesis history
PruneMode::Before(0) semantically prunes nothing, but its saturated target is 0, so this equality marks pruning as applied. The subsequent rebuild clears the table and skips block 0; the storage stage has the same issue at index_storage_history.rs:97. Standard provider fallback may mask the omission, but the persisted history index no longer honors the no-op mode.
Recommended Fix:
Return None from prune_target_block_with_min for Before(0), with account and storage tests showing Before(0) retains genesis while Before(1) excludes it.
| )?; | ||
| let prepared = prepare_history_shard_writes_serial::<tables::AccountsHistory, _>( | ||
| BTreeMap::from([(address, indices)]), | ||
| |key| self.provider.get::<tables::AccountsHistory>(key), |
There was a problem hiding this comment.
🛡️ [DEFENSE-IN-DEPTH] Public batch append helpers can overwrite pending history updates
This committed-state read occurs inside an already-open batch. A second append for the same logical key misses the first pending put and overwrites it; auto-commit can make visibility threshold-dependent. The storage helper has the same contract violation. Callers are currently test-only, but both methods are public and conflict with the read-before-batch protocol introduced by this PR.
Recommended Fix:
Restrict both helpers to tests or crate scope, or accept all grouped keys at once so one update per logical key is structurally enforced.
|
This PR has been marked stale due to 7 days of inactivity. |
|
Closed due to inactivity. Reopen if still needed. |
Mirrors paradigmxyz/reth#26766 for Cyclops review.
Supersedes #26765, which only parallelized incremental
IndexStorageHistory. This covers both history tables, in both the pipeline and live persist.The expensive bit is the committed get of each key's last shard (
highest_block = u64::MAX). On unique-slot (and unique-account) workloads, serial gets cannot keep up with 2s blocks. #25282 already parallelized it inwrite_storage_history.write_account_historyand the incremental index stages were still serial, and the stage path did the gets insidewith_rocksdb_batch_auto_commit.Last-shard gets read committed state only (they do not see pending batch puts). They must finish and join before the write batch is created so a key is never read after it has been put, and so parallel RocksDB gets do not overlap auto-commit
write_opt. MDBXDbTxis not safe for concurrent gets. So: group new indices, finish all last-shard reads (Rayon on RocksDB, serial on MDBX) and join, then open the batch and put. Puts stay serial on purpose.first_syncappend-only is unchanged and never touches last shards.--fullsnapshot restore does not ship RocksDB indexes. The stage now computesrebuild_from_emptyfrom the durable checkpoint before prune jumps the in-memory checkpoint totip - 10064, so that first execute clears the empty table and append-only indexes the prune window ((tip - 10063)..=tip, 10064 blocks). Parallel last-shard reads are for live persist and incremental stage restarts (checkpoint != 0), not that first--fullexecute.Cherry-picked onto
v2.5.0(nothing else from main) and A/B'd a Base Sepolia--fullrestore on ani7i.16xlarge(snapshot block 45,664,656, then ~35–39k blocks of catchup):IndexStorageHistorystuck atLoading indicesfor 30+ minutes. Checkpoint frozen, ~1 core, page-cache reads, almost no disk. Never reachedWriting indices. That node took the incremental last-shard path because prune bumped the checkpoint beforefirst_syncwas computed.--fullfirst execute is clear + append-only over the prune window. Catchup and live persist still use the two-phase last-shard plan.Test plan
history_shardsunit tests (rechunk, serial==parallel, overlapping gets on a dedicated pool)--fullsnapshot restore + catchup vs unpatched v2.5.0Prompted by: @joshieDo