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

ConnectionPool hangs in thin mode when timeout is not None #166

Closed
lpetre-ulb opened this issue Apr 11, 2023 · 5 comments
Closed

ConnectionPool hangs in thin mode when timeout is not None #166

lpetre-ulb opened this issue Apr 11, 2023 · 5 comments
Labels
bug Something isn't working patch available

Comments

@lpetre-ulb
Copy link

Hello,

while porting my project to use a ConnectionPool instead of many Connection, I stumbled across an issue when:

  • using the thin mode;
  • setting the timeout to an integer (so not None);
  • and using a dynamic number of connections (i.e. min != max).

In this specific case, the ConnectionPool.acquire() hangs and never returns a connection. I could identify the problem as due to to the following while loop. I'm not familiar enough with the library intrinsics to provide a PR though.

while self.get_open_count() > self.min and conn_impls_to_check:
conn_impl = conn_impls_to_check[0]
if current_time - conn_impl._time_in_pool > self._timeout:
conn_impls_to_check.pop(0)
self._drop_conn_impl(conn_impl)

The project uses Python 3.8.13 with oracledb 1.3.1. The problem is however present since the feature implementation in c7c0d55.

Please find a minimal reproducible example below. The script blocks and never completes, staying in an endless loop in ConnectionPool.acquire().

import oracledb
from multiprocessing.pool import ThreadPool

pool = oracledb.create_pool("<REDACTED>", config_dir="/etc", min=1, max=5, timeout=10)
thread_pool = ThreadPool(processes = 5)

def wait(i):
  with pool.acquire() as connection:
    with connection.cursor() as cursor:
      cursor.execute("""
        BEGIN
          DBMS_SESSION.sleep(1);
        END; """)
      print(f"Done {i}")

for i in range(10):
  thread_pool.apply_async(wait, args=[i])

Thank you for any help. Let me know if you need more informations.

@anthony-tuininga anthony-tuininga added the bug Something isn't working label Apr 11, 2023
@anthony-tuininga
Copy link
Member

Thanks for the report. This will get addressed in the next release!

@lpetre-ulb
Copy link
Author

Wonderful! Thank you for your prompt answer.

@anthony-tuininga
Copy link
Member

I have pushed a patch that should correct this issue. If you are able to build from source you can verify that it corrects your issue as well.

@anthony-tuininga
Copy link
Member

This has been included in version 1.3.1 which was just released!

@lpetre-ulb
Copy link
Author

Hello, all my apologies for the delayed reply. I confirm that the bug is indeed fixed in version 1.3.1. Thank you for the patch and the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch available
Projects
None yet
Development

No branches or pull requests

2 participants