Conversation
simon-20
requested changes
Sep 24, 2026
simon-20
left a comment
Contributor
There was a problem hiding this comment.
This is good @Mzsd. I have just one request:
Returning 503 Service Unavailable implicitly tells the client they should try again later.
But some of the errors that are subclasses of sqlalchemy.exc.DBAPIError (e.g., IntegrityError) are not errors that will be fixed by retrying.
So, I would suggest:
- separate off the handling of
OperationErrorandAdminShutdown(and any other database errors you can find in the docs that are clearly runtime errors) and return 503 for them - handle DBAPIError after the above and return 500 for it
Author
Ok I will adjust that bit - thanks |
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.
Summary
Fixes a crash when the Postgres connection is dropped or interrupted (e.g.
psycopg.errors.AdminShutdown,OperationalError). Previously this reached the generic unhandled exception handler and surfaced as a bare 500 with no indication it was a database issue, reproduced locally by running RYD against a real Postgres container and killing the backend serving its pooled connection mid-session, which crashed the request and produced a "Server Error" page oniati-account-web, matching the traceback in the issue.Changes
pool_pre_pingon the FGA provider's SQLAlchemy engine, so a dead pooled connection is detected and silently replaced before use instead of failing the request that draws it from the pool. Verified this prevents the crash: killing the backend connection and repeating the same request no longer errors.sqlalchemy.exc.DBAPIError, so any connection failure that still slips through is logged clearly as a database error and returned as a 503 rather than 500.Files changed
Related issues
Closes #69 - Psycopg database connection exceptions are not handled