fix: prevent global lock leak in db_proxy commit() and pool guard#300
Open
remo-lab wants to merge 1 commit intoHSF:masterfrom
Open
fix: prevent global lock leak in db_proxy commit() and pool guard#300remo-lab wants to merge 1 commit intoHSF:masterfrom
remo-lab wants to merge 1 commit intoHSF:masterfrom
Conversation
Signed-off-by: remo-lab <remopanda7@gmail.com>
Author
|
Hi @mightqxc , this PR fixes a deadlock caused by a DB lock not being released on commit() failure. |
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.
Description
This PR fixes a deadlock issue in PandaHarvester caused by a global DB lock not being released when
commit()fails.If a database error occurred during
commit(), the application-level lock remained held, which could block all Harvester threads and freeze the system until a restart.Fix
The lock release logic in
commit()is moved into afinallyblock so it is always executed, even when an exception is raised. This follows the same safe pattern already used inrollback().A small defensive fix is also added in the DB connection pool to ensure a connection is only returned to the pool if it was successfully acquired.
Files Changed
pandaharvester/harvestercore/db_proxy.pypandaharvester/harvestercore/db_proxy_pool.pyImpact