apollo_storage: Use watch channels for marker tracking#12690
Open
dean-starkware wants to merge 1 commit intodean/storage-batching-init-fixfrom
Open
apollo_storage: Use watch channels for marker tracking#12690dean-starkware wants to merge 1 commit intodean/storage-batching-init-fixfrom
dean-starkware wants to merge 1 commit intodean/storage-batching-init-fixfrom
Conversation
matanl-starkware
requested changes
Feb 18, 2026
Collaborator
matanl-starkware
left a comment
There was a problem hiding this comment.
@matanl-starkware reviewed 2 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on dean-starkware).
crates/apollo_central_sync/src/lib.rs line 941 at r1 (raw file):
// Skip forward through blocks without declared classes. while from < state_marker { let txn = reader.begin_ro_txn()?;
Here you don't have pending writes...
Code quote:
reader.begin_ro_txn()1081b9f to
d1ec325
Compare
a9146ee to
7775b79
Compare
7775b79 to
1752bb2
Compare
1752bb2 to
4d74a1e
Compare
1d6cf39 to
57f79bb
Compare
73c95bd to
e15217f
Compare
54a2710 to
d05a88d
Compare
e15217f to
a2a3cea
Compare
d05a88d to
4700a60
Compare
a2a3cea to
ad30d3f
Compare
ad30d3f to
cf93686
Compare
09de6c9 to
d538938
Compare
dean-starkware
commented
Feb 22, 2026
Author
dean-starkware
left a comment
There was a problem hiding this comment.
@dean-starkware made 1 comment.
Reviewable status: 0 of 14 files reviewed, 1 unresolved discussion (waiting on matanl-starkware).
crates/apollo_central_sync/src/lib.rs line 941 at r1 (raw file):
Previously, matanl-starkware (Matan Lior) wrote…
Here you don't have pending writes...
Already fixed.
cf93686 to
a24793b
Compare
216db74 to
85494d3
Compare
06d7ff2 to
92d7bfe
Compare
…ility bugs Replace direct DB marker reads in stream generators with tokio::sync::watch channels, eliminating spawn_blocking and MDBX thread-affinity issues. Remove spawn_blocking from perform_storage_writes to prevent MDBX TLS violations that caused State marker mismatches when batching was enabled. Switch compiler_backward_compatibility_marker and compiled_class_marker reads from begin_ro_txn to begin_rw_txn so they see uncommitted batched writes, fixing Class marker mismatches. Co-authored-by: Cursor <cursoragent@cursor.com>
92d7bfe to
fc546ad
Compare
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.
Replace spawn_blocking-based marker reads with tokio::sync::watch channels. This eliminates the MDBX Thread Local Storage issue where uncommitted writes from one thread were not visible to reads from another thread in the blocking pool.
Note
Medium Risk
Changes core sync concurrency/marker propagation and compiled-class download flow; mistakes could stall progress or skip required compiled classes under certain config/compatibility conditions.
Overview
Sync now tracks
header/statemarkers viatokio::sync::watchchannels, updating them after each successful write, so block/state streams no longer poll storage each loop (avoids cross-thread MDBX visibility issues with batched/uncommitted writes).Compiled class syncing is reworked from range-based
stream_compiled_classesscanning markers to an event-driven model: after storing a state diff, the sync enqueues per-classCompiledClassRequests and fetches each CASM viaget_compiled_class, while switching several validation/lookup reads to use the writer’s RW transaction for consistency. Tests are updated to mockget_compiled_classcalls, and storage batching commit logic is slightly adjusted (removes a stray blank line only).Written by Cursor Bugbot for commit fc546ad. This will update automatically on new commits. Configure here.