Skip to content

fix(server): Always reject envelopes when shutting down and non-ephemeral#6226

Open
klochek wants to merge 4 commits into
masterfrom
christopherklochek/fix_shutdown_flake
Open

fix(server): Always reject envelopes when shutting down and non-ephemeral#6226
klochek wants to merge 4 commits into
masterfrom
christopherklochek/fix_shutdown_flake

Conversation

@klochek

@klochek klochek commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

When we are in the shutting down state (and non-ephemeral), we aren't guaranteed to close the channel fast enough to reject all incoming envelopes. Add back the shutdown handle, but also check to see if we're non-ephemeral. Fixes a flaky test I ran into.

…eral

When we are in the shutting down state (and non-ephemeral), we aren't guaranteed to close the channel fast enough to reject all incoming envelopes.  Add back the shutdown handle, but also check to see if we're non-ephemeral.  Fixes a flaky test I ran into.
@klochek
klochek requested a review from a team as a code owner July 14, 2026 15:06
Comment thread relay-server/src/services/buffer/mod.rs Outdated
Comment thread relay-server/src/services/buffer/mod.rs Outdated
pub fn try_push(&self, envelope: Managed<Box<Envelope>>) -> Result<(), Rejected<PushError>> {
if self.addr.is_closed() {
// This happens for inflight requests when `ephemeral: false`.
let permanent_shutting_down = !self.is_ephemeral && self.shutdown_handle.shutting_down();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be 'just' another atomic check, but worth keeping an eye on performance metrics on rollout as every request will go through this check, in case it's more than just an atomic (backed by a Tokio Watch).

Comment thread relay-server/src/services/buffer/mod.rs Outdated
@klochek
klochek added this pull request to the merge queue Jul 15, 2026
@klochek
klochek removed this pull request from the merge queue due to a manual request Jul 15, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 77fa440. Configure here.

Comment thread relay-system/src/controller.rs Outdated

@jjbayer jjbayer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can make this more local: The envelope buffer already gets notified of the shutdown, so it could store an atomic bool on EnvelopeBufferMetrics immediately after shutdown.notified() (before calling Self::handle_shutdown).

Then try_push can simply check self.metrics.is_shutting_down. We might want to rename metrics to something more generic though, because it would now contain more than metrics.

Comment thread relay-system/src/controller.rs Outdated
@jjbayer
jjbayer dismissed their stale review July 17, 2026 08:05

My comment is still relevant but I won't be available to approve the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants