Skip to content

feat(server): Accept inflight requests during shutdown#5769

Merged
jjbayer merged 3 commits intomasterfrom
fix/server-inflight-request
Mar 27, 2026
Merged

feat(server): Accept inflight requests during shutdown#5769
jjbayer merged 3 commits intomasterfrom
fix/server-inflight-request

Conversation

@jjbayer
Copy link
Copy Markdown
Member

@jjbayer jjbayer commented Mar 26, 2026

With #5746 and #5751, we should be able to process all inflight requests even during shutdown.

Previous behavior:

  1. Relay receives SIGTERM
  2. All inflight requests (i.e. requests that have not been written into the buffer) are rejected with 503

New behavior:

  1. Relay receives SIGTERM
  2. Depending on spool.envelopes.ephemeral:
    1. if true (which it is in SaaS), the envelope buffer service will keep accepting & processing envelopes until the process is killed. Inflight requests are accepted with 200 because the Addr of the envelope buffer service is still open.
    2. if false, the envelope buffer will flush its in-memory state to disk and stop accepting envelopes. Inflight requests are rejected with 503 like before.

Note that the axum server rejects all requests once the shutdown signal has been received, so this only affects requests that are already being handled while the envelope buffer shuts down.

Fixes INGEST-510

@linear-code
Copy link
Copy Markdown

linear-code bot commented Mar 26, 2026

Comment on lines -68 to -74
# After relay exits, new connections are refused.
relay.wait_for_exit(timeout=10)
try:
socket.create_connection((host, port))
assert False, "Expected connection to be refused after relay exited"
except ConnectionRefusedError:
pass
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This takes a long time and was not really the purpose of the test.

@jjbayer jjbayer marked this pull request as ready for review March 26, 2026 15:23
@jjbayer jjbayer requested a review from a team as a code owner March 26, 2026 15:23
Comment thread relay-server/src/services/buffer/mod.rs
@jjbayer jjbayer changed the title Save inflight requests on shutdown feat(server): Save inflight requests on shutdown Mar 27, 2026
@loewenheim
Copy link
Copy Markdown
Contributor

I might be lacking a bit of context from the previous PRs, but can you elaborate on how this change "saves" the requests?

@jjbayer jjbayer changed the title feat(server): Save inflight requests on shutdown feat(server): Accept inflight requests during shutdown Mar 27, 2026
@jjbayer
Copy link
Copy Markdown
Member Author

jjbayer commented Mar 27, 2026

I might be lacking a bit of context from the previous PRs, but can you elaborate on how this change "saves" the requests?

@loewenheim I added more details to the PR description, I hope this clarifies things. I also changed the word "save" to "accept" because "save" is ambiguous.

@loewenheim
Copy link
Copy Markdown
Contributor

Thanks, the additional details clear it up.

@jjbayer jjbayer added this pull request to the merge queue Mar 27, 2026
Merged via the queue into master with commit c74d272 Mar 27, 2026
33 of 34 checks passed
@jjbayer jjbayer deleted the fix/server-inflight-request branch March 27, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants