mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
database: handle nested transaaction when trying to close before transaction (PROJQUAY-3303) (#1157)
* Revert "database: force close existing non-pooled connections before transaction (PROJQUAY-3303) (#1153)"
This reverts commit 7cdb88b578.
* database: handle nested transaaction when trying to close before transaction (PROJQUAY-3303)
Handle nested transaction when trying to catch InterfaceError from
pymsql/mysql's idle connections. If the connection is already in a
transaction, then we'll assume it doesn't need to be closed
beforehand, as it's probably in-use, and unlikely to be cleaned up.
This commit is contained in:
committed by
GitHub
parent
7162be3791
commit
24b3c15334
@@ -216,7 +216,13 @@ class DefaultConfig(ImmutableConfig):
|
||||
# to reopen a new session to MySQL. This should only applies to non-registry workers,
|
||||
# as the registry workers use a pool by default, and shouldn't have this issue.
|
||||
if type(db.obj).__name__ == "ObservableRetryingMySQLDatabase":
|
||||
db.close()
|
||||
try:
|
||||
db.close()
|
||||
except:
|
||||
# Only try to close the connection. Otherwise closing connections in a nested transaction
|
||||
# will return an OperationalError. In that case, we can just continue with the normal flow,
|
||||
# as we know the connection is likely in use and not stale.
|
||||
pass
|
||||
|
||||
return db.transaction()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user