Skip to content

fix: prevent global lock leak in db_proxy commit() and pool guard#300

Open
remo-lab wants to merge 1 commit intoHSF:masterfrom
remo-lab:fix/db-proxy-commit-lock-leak
Open

fix: prevent global lock leak in db_proxy commit() and pool guard#300
remo-lab wants to merge 1 commit intoHSF:masterfrom
remo-lab:fix/db-proxy-commit-lock-leak

Conversation

@remo-lab
Copy link

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 a finally block so it is always executed, even when an exception is raised. This follows the same safe pattern already used in rollback().

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.py
  • pandaharvester/harvestercore/db_proxy_pool.py

Impact

  • Prevents system-wide deadlocks on database failures
  • Allows the system to recover gracefully without restarts
  • No change to normal success paths

Signed-off-by: remo-lab <remopanda7@gmail.com>
@remo-lab
Copy link
Author

Hi @mightqxc , this PR fixes a deadlock caused by a DB lock not being released on commit() failure.
The change ensures the lock is always released and adds a small guard in the connection pool.
Would appreciate a review. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant