Skip to content

apollo_storage: always spawn storage reader server, return 503 when disabled#12836

Merged
nadin-Starkware merged 1 commit intomainfrom
02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled
Mar 10, 2026
Merged

apollo_storage: always spawn storage reader server, return 503 when disabled#12836
nadin-Starkware merged 1 commit intomainfrom
02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled

Conversation

@nadin-Starkware
Copy link
Copy Markdown
Collaborator

@nadin-Starkware nadin-Starkware commented Feb 24, 2026

Note

Medium Risk
Touches shared storage/server wiring used across multiple components and changes disabled-mode behavior from “no listener” to “listener that 503s”, which may affect operational expectations and port allocation.

Overview
Storage now always creates and spawns the storage reader server (no more Option), and a disabled server returns 503 Service Unavailable to all requests instead of not starting.

This updates batcher, state-sync, and class-manager to hold a mandatory keep-alive AbortHandle, switches call sites to storage_reader_server.spawn(), and adjusts tests/integration configs to allocate distinct storage-reader ports (including a new class-manager test identifier and updated hybrid overlay port).

Written by Cursor Bugbot for commit ecdc945. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Collaborator Author

nadin-Starkware commented Feb 24, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from 35e3331 to 3cdf781 Compare February 24, 2026 14:36
Comment thread crates/apollo_storage/src/storage_reader_server.rs
Comment thread crates/apollo_storage/src/storage_reader_server.rs
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch 3 times, most recently from f7283ec to 96ae2cc Compare February 25, 2026 06:38
@nadin-Starkware nadin-Starkware changed the base branch from main-v0.14.2 to graphite-base/12836 February 25, 2026 06:39
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from 96ae2cc to 0cdbfc7 Compare February 25, 2026 06:39
@nadin-Starkware nadin-Starkware changed the base branch from graphite-base/12836 to 02-25-apollo_storage_abort_storage_reader_server_handles_on_drop February 25, 2026 06:39
@graphite-app graphite-app Bot changed the base branch from 02-25-apollo_storage_abort_storage_reader_server_handles_on_drop to main-v0.14.2 February 25, 2026 06:40
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Feb 25, 2026

Merge activity

  • Feb 25, 6:40 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Mar 4, 9:24 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Mar 4, 9:24 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..

@nadin-Starkware nadin-Starkware changed the base branch from main-v0.14.2 to graphite-base/12836 February 25, 2026 06:46
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from 0cdbfc7 to d58eb47 Compare February 25, 2026 06:47
@nadin-Starkware nadin-Starkware changed the base branch from graphite-base/12836 to 02-25-apollo_storage_abort_storage_reader_server_handles_on_drop February 25, 2026 06:47
Comment thread crates/apollo_class_manager/src/class_storage.rs Outdated
Comment thread crates/apollo_batcher/src/batcher.rs
Comment thread crates/apollo_state_sync/src/runner/mod.rs
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch 3 times, most recently from 864a715 to c40ebc9 Compare February 25, 2026 07:47
Comment thread crates/apollo_class_manager/src/test_utils.rs Outdated
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch 4 times, most recently from 9b1dbae to ee8fcae Compare February 25, 2026 10:17
@nadin-Starkware nadin-Starkware force-pushed the 02-25-apollo_storage_abort_storage_reader_server_handles_on_drop branch from d03261e to 219b0b8 Compare February 25, 2026 10:17
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch 2 times, most recently from d92b304 to b518f9b Compare February 25, 2026 10:56
@nadin-Starkware nadin-Starkware force-pushed the 02-25-apollo_storage_abort_storage_reader_server_handles_on_drop branch from 219b0b8 to 375935d Compare February 25, 2026 10:56
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from a434618 to 7f6202f Compare March 4, 2026 09:33
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread crates/apollo_class_manager/src/test_utils.rs Outdated
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch 7 times, most recently from 913ec55 to 311ad1a Compare March 5, 2026 12:39
@nadin-Starkware nadin-Starkware changed the base branch from main-v0.14.2 to graphite-base/12836 March 9, 2026 13:25
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from 311ad1a to 8b377ad Compare March 9, 2026 13:25
@nadin-Starkware nadin-Starkware changed the base branch from graphite-base/12836 to main March 9, 2026 13:25
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch 2 times, most recently from 79b46be to 10e5ece Compare March 9, 2026 14:29
Copy link
Copy Markdown
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Itay-Tsabary-Starkware made 2 comments.
Reviewable status: 0 of 20 files reviewed, 1 unresolved discussion (waiting on nadin-Starkware).


crates/apollo_storage/src/storage_reader_server.rs line 161 at r12 (raw file):

            storage_reader: self.storage_reader.clone(),
            enabled: self.enabled,
            _phantom: PhantomData,

Is this still required? Even if not, can be in a different pr

Code quote:

_phantom: PhantomData,

crates/apollo_storage/src/storage_reader_server.rs line 202 at r12 (raw file):

    {
        let socket = SocketAddr::from((self.config.ip(), self.config.port()));
        let enabled_status = if self.config.is_enabled() { "enabled" } else { "disabled" };

IMO:

  1. either define a proper enum instead of using a boolean value
  2. print "is_enabled: {bool value}
    2 is simpler

Copy link
Copy Markdown
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Itay-Tsabary-Starkware made 2 comments.
Reviewable status: 0 of 20 files reviewed, 3 unresolved discussions (waiting on nadin-Starkware).


crates/apollo_storage/src/storage_reader_server_test.rs line 114 at r12 (raw file):

    let mut available_ports =
        AvailablePorts::new(TestIdentifier::StorageReaderServerUnitTests.into(), 2);

Should be using the unique_id! macro

Code quote:

2

crates/apollo_storage/src/storage_reader_server_test.rs line 169 at r12 (raw file):

    let mut available_ports =
        AvailablePorts::new(TestIdentifier::StorageReaderServerUnitTests.into(), 4);

Should be using the unique_id! macro
(throughout)

Code quote:

4

Copy link
Copy Markdown
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Itay-Tsabary-Starkware made 1 comment.
Reviewable status: 0 of 20 files reviewed, 4 unresolved discussions (waiting on nadin-Starkware).


deployments/sequencer/configs/overlays/hybrid/testing/node-0/services/core.yaml line 104 at r12 (raw file):

  - name: state-sync-storage-reader
    port: 55014
    targetPort: 55014

why?

Code quote:

    port: 55014
    targetPort: 55014

Copy link
Copy Markdown
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Itay-Tsabary-Starkware made 1 comment.
Reviewable status: 0 of 20 files reviewed, 4 unresolved discussions (waiting on nadin-Starkware).


crates/apollo_class_manager/src/class_storage.rs line 289 at r12 (raw file):

        let storage_reader_server_handle = Arc::new(tokio::spawn(async {}).abort_handle());
        Ok(Self { reader, writer: Arc::new(Mutex::new(writer)), storage_reader_server_handle })
    }

Let's keep as is for this pr, but we should change this, this essentially having another config value (run the server or the mock process) manifested as a different function.
If no other alternatives I'd even prefer we actually have this as a config value.
Could you come up with some other way? A dependency injection of some sort?

Code quote:

    pub fn new(
        storage_config: StorageConfig,
        storage_reader_server_config: ServerConfig,
    ) -> ClassHashStorageResult<Self> {
        let (reader, writer, storage_reader_server) =
            apollo_storage::open_storage_with_metric_and_server::<
                GenericStorageReaderServerHandler,
                StorageReaderRequest,
                StorageReaderResponse,
            >(
                storage_config,
                &CLASS_MANAGER_STORAGE_OPEN_READ_TRANSACTIONS,
                storage_reader_server_config,
            )?;

        let storage_reader_server_handle = Arc::new(storage_reader_server.spawn());

        Ok(Self { reader, writer: Arc::new(Mutex::new(writer)), storage_reader_server_handle })
    }

    /// Opens the storage without a storage reader server or metrics.
    #[cfg(any(feature = "testing", test))]
    pub(crate) fn new_plain(storage_config: StorageConfig) -> ClassHashStorageResult<Self> {
        let (reader, writer) = open_storage(storage_config)?;
        let storage_reader_server_handle = Arc::new(tokio::spawn(async {}).abort_handle());
        Ok(Self { reader, writer: Arc::new(Mutex::new(writer)), storage_reader_server_handle })
    }

@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from 10e5ece to 44668ae Compare March 10, 2026 08:35
Copy link
Copy Markdown
Collaborator Author

@nadin-Starkware nadin-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nadin-Starkware made 4 comments.
Reviewable status: 0 of 20 files reviewed, 4 unresolved discussions (waiting on Itay-Tsabary-Starkware).


crates/apollo_storage/src/storage_reader_server.rs line 202 at r12 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

IMO:

  1. either define a proper enum instead of using a boolean value
  2. print "is_enabled: {bool value}
    2 is simpler

Done.


crates/apollo_storage/src/storage_reader_server_test.rs line 114 at r12 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Should be using the unique_id! macro

Done in separate PR


crates/apollo_storage/src/storage_reader_server_test.rs line 169 at r12 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Should be using the unique_id! macro
(throughout)

Done in separate PR


deployments/sequencer/configs/overlays/hybrid/testing/node-0/services/core.yaml line 104 at r12 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

why?

55012 is also used by the proof_manager component. There were no conflicts before because the server was disabled, but once we changed it to always spawn, a conflict occurred. So I changed the port to make it unique

Copy link
Copy Markdown
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@Itay-Tsabary-Starkware reviewed 13 files and all commit messages, made 1 comment, and resolved 4 discussions.
Reviewable status: 13 of 20 files reviewed, all discussions resolved.

@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from 44668ae to ca3cd9e Compare March 10, 2026 11:33
@nadin-Starkware nadin-Starkware force-pushed the 02-24-apollo_storage_always_spawn_storage_reader_server_return_503_when_disabled branch from ca3cd9e to ecdc945 Compare March 10, 2026 13:09
Copy link
Copy Markdown
Collaborator Author

@nadin-Starkware nadin-Starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nadin-Starkware reviewed 7 files.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on nadin-Starkware).

@nadin-Starkware nadin-Starkware added this pull request to the merge queue Mar 10, 2026
Merged via the queue into main with commit 715f0a4 Mar 10, 2026
22 of 23 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants