test(io): add test_graceful_shutdown_waits_for_in_flight_request#4714
Merged
steve-chavez merged 1 commit intoPostgREST:mainfrom Mar 12, 2026
Merged
test(io): add test_graceful_shutdown_waits_for_in_flight_request#4714steve-chavez merged 1 commit intoPostgREST:mainfrom
steve-chavez merged 1 commit intoPostgREST:mainfrom
Conversation
Comment on lines
+110
to
+127
| "SIGTERM should allow in-flight requests to finish before exiting" | ||
|
|
||
| with run(env=defaultenv, wait_max_seconds=5) as postgrest: | ||
|
|
||
| def sleep(): | ||
| response = postgrest.session.get("/rpc/sleep?seconds=3", timeout=10) | ||
| assert response.text == "" | ||
| assert response.status_code == 204 | ||
|
|
||
| t = Thread(target=sleep) | ||
| t.start() | ||
|
|
||
| # Wait for the request to be in-flight before shutting down. | ||
| time.sleep(1) | ||
|
|
||
| postgrest.process.terminate() | ||
|
|
||
| t.join() |
Member
There was a problem hiding this comment.
Following up on the discussion in #4702 (comment), the pg connection is left running while postgREST shuts down.
I was thinking the right behavior is to also kill the connection immediately.
But on postgres that behavior happens under SIGINT, SIGTERM is the smart shutdown mode (ref). So this looks correct.
Collaborator
Author
There was a problem hiding this comment.
@steve-chavez I guess I don't understand how it affects the test itself. Do you want to have different scenarios for SIGINT and SIGTERM?
Member
There was a problem hiding this comment.
Nope, it was just a comment so we don't forget (thinking out loud). All good here.
steve-chavez
approved these changes
Mar 12, 2026
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.
DISCLAIMER:
This commit was authored entirely by a human without the assistance of LLMs.
Test to validate graceful shutdown. Marked as
xfailto make sure it fails.Prerequisite of: #4702