AsyncConnectionPool: a session_callback that raises leaves the connection counted busy, so acquire() later hangs

Offen
#626 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
75/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
database

Rechercherichtung

Start at the async connection pool's acquire path and trace how it handles a session_callback exception; compare it with the sync pool behavior described in the issue. Add or update a regression test using max=1 and a callback that raises once, checking that a subsequent acquire succeeds and the pool no longer counts the failed connection as busy.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the problem

If a pool's session_callback raises, acquire() raises the error, but the pool still counts the new connection as busy. In an AsyncConnectionPool, that connection is never returned. Once the pool is at max, every later acquire() waits for ever.

A sync pool also leaves busy at 1 after the failure, but its next acquire() succeeded in my test.

Calling pool.drop(connection) inside the callback before re-raising works around it: busy and opened go back to 0.

Versions

  • python-oracledb 26.0.1, Thin mode
  • Python 3.13.6, macOS (arm64)
  • Oracle Database Free 23.26 (gvenzl/oracle-free:23-faststart)

To reproduce

import asyncio, gc
import oracledb

async def main(dsn, user, password):
    calls = 0

    async def callback(connection, tag):
        nonlocal calls
        calls += 1
        if calls == 1:
            raise RuntimeError("refused")

    pool = oracledb.create_pool_async(user=user, password=password, dsn=dsn, min=0, max=1,
                                      session_callback=callback)
    try:
        await pool.acquire()
    except RuntimeError:
        pass
    gc.collect()
    print("busy", pool.busy, "opened", pool.opened)   # busy 1 opened 1
    await asyncio.wait_for(pool.acquire(), 15)        # TimeoutError

Output:

busy 1 opened 1
TimeoutError   (second acquire, after 15 s)

Expected

When the session callback fails, the pool should drop the connection (or release it), so the next acquire() can open a new session.

Vorherrschende Sprache
Python
Sterne
456
Forks
119
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus oracle/python-oracledb

Alle Issues in oracle/python-oracledb

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.