oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
890 stars 361 forks source link

Pool initiated Sessions are cleaned-up automatically and each connection request creating extra sessions #649

Closed Ashok-Bottu closed 1 year ago

Ashok-Bottu commented 1 year ago
  1. What versions are you using? Django 3.2.4 Python 3.9.6 cx-oracle : 8.3.0 database version: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.18.0.0.0
  1. Is it an error or a hang or a crash? Issue: Back-end service sometimes executes in ~2secs(end to end) and same service few times performs with ~12secs. Upon application loggers, understood that db connection acquiring is actually taking time at times.
    It has been noted from v$session that, dedicated pool sessions are created again and again for each connection query execution.

  2. What error(s) or behavior you are seeing? Noted Pattern:

    • On boot-up of Application, pool is initiated and number of sessions are created as per MIN configuration(below is sample configuration).
    • each time, a connection/session is retrieved from pool, it actually creating that many new sessions as per MIN value at pool configuration.
    • with the above behavior, the initially created sessions are auto-cleaned up and new sessions are getting created for every backend service execution.

      apps.py pool = cx_Oracle.SessionPool(user=os.environ.get("DB_USER"), password=os.environ.get("DB_PWD"), dsn=dsn, min=5, max=10, encoding="UTF-8" )

      • defined a separate class where getting a connection from pool.

      db_manager.py: class Connection: def init(self): self.connection = pool.acquire() def exit(self, cur_coll=None, *args, **kwargs): pool.release(self.connection)

      sample_service.py def api_get_data(request): with Connection() as connection:

      • query execution and send the data back as api response *

please let me know, if need more details here.

  1. Include a runnable Python script that shows the problem.
cjbj commented 1 year ago

Include a runnable Python script that shows the problem.

Please provide such a script. A small script. Is some timeout like a firewall killing all your connections?

stale[bot] commented 1 year ago

This issue has been automatically marked as inactive because it has not been updated recently. It will be closed if no further activity occurs. Thank you for your contributions.

cjbj commented 1 year ago

Closing - no activity.