Skip to content
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

Fix concurrent initialization of connection pool #1825

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

henadzit
Copy link
Contributor

@henadzit henadzit commented Dec 24, 2024

Description

This PR fixes the issue where when multiple concurrent tasks start queries or transactions, multiple connection pools are initialized that leads to

  • Using more database connections than configured
  • Running into the connections limit

The PR adds an extra lock that is used when the connection pool is initialized.

Motivation and Context

This should fix #1811.

How Has This Been Tested?

make ci

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@coveralls
Copy link

coveralls commented Dec 24, 2024

Pull Request Test Coverage Report for Build 12484477661

Details

  • 31 of 34 (91.18%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 90.214%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/backends/base_postgres/client.py 2 3 66.67%
tortoise/backends/oracle/client.py 0 2 0.0%
Totals Coverage Status
Change from base Build 12473889377: 0.07%
Covered Lines: 6392
Relevant Lines: 6971

💛 - Coveralls

@henadzit henadzit requested a review from abondar December 24, 2024 17:15
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.

Pool.release() received invalid connection
2 participants