Skip to content

test(io): add test_graceful_shutdown_waits_for_in_flight_request#4714

Merged
steve-chavez merged 1 commit intoPostgREST:mainfrom
mkleczek:graceful-shutdown-failing
Mar 12, 2026
Merged

test(io): add test_graceful_shutdown_waits_for_in_flight_request#4714
steve-chavez merged 1 commit intoPostgREST:mainfrom
mkleczek:graceful-shutdown-failing

Conversation

@mkleczek
Copy link
Copy Markdown
Collaborator

DISCLAIMER:
This commit was authored entirely by a human without the assistance of LLMs.

Test to validate graceful shutdown. Marked as xfail to make sure it fails.

Prerequisite of: #4702

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()
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.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@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?

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.

Nope, it was just a comment so we don't forget (thinking out loud). All good here.

@steve-chavez steve-chavez merged commit bee2ea6 into PostgREST:main Mar 12, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants