-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make database heartbeat more robust #21734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ def check_database_connection(session): | |
| if isinstance(session, scoped_session): | ||
| session = session() | ||
| trans = session.get_transaction() | ||
| if (trans and not trans.is_active) or session.connection().invalidated: | ||
| if trans and (not trans.is_active or session.connection().invalidated): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this affects anything: if condition satisifes, we only do I didn't find any mention of a connection-related side effect in case of a noop rollback, but I didn't dig too deep. That said, the edit doesn't do any harm, so if you think it's worth a try, that's fine.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this what happens:
Why else would this fix the integration tests ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also see the commit message for a different phrasing in case that's not clear ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooooh! You are right! We create a connection in the |
||
| session.rollback() | ||
| log.error("Database transaction rolled back due to inactive session transaction or invalid connection state.") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdavcs can you sanity check this ? the integration tests were causing postgres to run out of connections prior to this change, supposedly because
session.connection()checking out a connection and then never close it, so now we only check if there's an existing transaction.