{"record":{"id":"1ae86b2a4eea8353","repo":"t8y2/dbx","slug":"jdbc-session-was-quarantined-while-waiting-for-a-c","errorCode":null,"errorMessage":"JDBC Session was quarantined while waiting for a connection","messagePattern":"JDBC Session was quarantined while waiting for a connection","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agents/common/src/main/java/com/dbx/agent/AbstractJdbcAgent.java","lineNumber":369,"sourceCode":"        }\n\n        JdbcConnectionPoolRegistry.Lease borrowed;\n        try {\n            borrowed = borrowPooledConnection(registry, identity, params);\n        } catch (Exception error) {\n            synchronized (this) {\n                requestActive = false;\n                leasePinnedAtRequestStart = false;\n            }\n            throw error;\n        }\n\n        synchronized (this) {\n            if (pooledConnectionPoisoned) {\n                requestActive = false;\n                leasePinnedAtRequestStart = false;\n                borrowed.evict();\n                throw new IllegalStateException(\"JDBC Session was quarantined while waiting for a connection\");\n            }\n            pooledLease = borrowed;\n            connection = borrowed.connection();\n        }\n    }\n\n    final synchronized void finishPooledRequest(\n        JdbcExecutor executor,\n        boolean succeeded,\n        boolean requiresSessionAffinity,\n        boolean evictAfterRequest\n    ) {\n        if (poolRegistry == null) {\n            return;\n        }\n        requestActive = false;\n        if (pooledConnectionPoisoned) {\n            releasePooledConnection(true);","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/common/src/main/java/com/dbx/agent/AbstractJdbcAgent.java#L351-L387","documentation":"While a request was waiting to borrow a pooled connection, the underlying session was quarantined (pooledConnectionPoisoned set, typically due to a connection failure detected elsewhere). The library evicts the borrowed connection and throws this IllegalStateException instead of returning a bad connection.","triggerScenarios":"Concurrent/queued requests on the same agent session when another request poisons the pooled connection; pool eviction triggered by an earlier error while this request waited in the borrow queue.","commonSituations":"Database outage or failover while requests are queued; stale connections reaped; another thread's query killed the session.","solutions":["Retry the request on a fresh/reconnected session","Check database availability and pool health after quarantine","Enable pool validation/keep-alive so dead connections are detected before borrow","Serialize requests or use per-request sessions to avoid mid-wait poisoning"],"exampleFix":"// before\nagent.dispatchForRuntime(req); // may throw quarantine\n// after\ntry {\n    agent.dispatchForRuntime(req);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"quarantined\")) {\n        agent = recreateAndConnectAgent();\n        agent.dispatchForRuntime(req);\n    }\n}","handlingStrategy":"retry","validationCode":"if (agent.getConnection() == null) {\n    agent.connect(connectParams); // ensure a healthy session before queuing requests\n}","typeGuard":null,"tryCatchPattern":"try {\n    agent.dispatchForRuntime(req);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"quarantined\")) {\n        agent = recreateAgentWithPool(registry, connectParams);\n        agent.dispatchForRuntime(req); // bounded retry\n    }\n}","preventionTips":["Enable pool connection validation/keep-alive to catch dead connections early","Avoid sharing one agent session across many concurrent waiters; prefer per-request sessions","Monitor pool quarantine events and alert on database outages","Bound retries with backoff after a quarantine to let the pool recover"],"tags":["jdbc","connection-pool","quarantine","concurrency"],"backgroundTag":"pooled-connection-quarantined","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}