{"record":{"id":"66c542f92e1dae86","repo":"testcontainers/testcontainers-java","slug":"ex","errorCode":null,"errorMessage":"${ex}","messagePattern":"\\$\\{ex\\}","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/yugabytedb/src/main/java/org/testcontainers/containers/strategy/YugabyteDBYSQLWaitStrategy.java","lineNumber":51,"sourceCode":"    private static final String YSQL_EXTENDED_PROBE =\n        \"CREATE TABLE IF NOT EXISTS YB_SAMPLE(k int, v int, primary key(k, v))\";\n\n    private static final String YSQL_EXTENDED_PROBE_DROP_TABLE = \"DROP TABLE IF EXISTS YB_SAMPLE\";\n\n    @Override\n    public void waitUntilReady(WaitStrategyTarget target) {\n        YugabyteDBYSQLContainer container = (YugabyteDBYSQLContainer) target;\n        retryUntilSuccess(\n            (int) startupTimeout.getSeconds(),\n            TimeUnit.SECONDS,\n            () -> {\n                getRateLimiter()\n                    .doWhenReady(() -> {\n                        try (Connection con = container.createConnection(\"\"); Statement stmt = con.createStatement()) {\n                            stmt.execute(YSQL_EXTENDED_PROBE);\n                            stmt.execute(YSQL_EXTENDED_PROBE_DROP_TABLE);\n                        } catch (SQLException ex) {\n                            throw new RuntimeException(ex);\n                        }\n                    });\n                return true;\n            }\n        );\n    }\n\n    @Override\n    public void waitUntilReady() {\n        waitUntilReady(target);\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":64,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/yugabytedb/src/main/java/org/testcontainers/containers/strategy/YugabyteDBYSQLWaitStrategy.java#L33-L64","documentation":"YugabyteDBYSQLWaitStrategy probes YSQL readiness by executing an extended probe query via JDBC; any SQLException during the probe is wrapped in a RuntimeException with the SQLException as message/cause, failing the wait strategy attempt so it retries until timeout.","triggerScenarios":"waitUntilReady's doWhenReady callback calls container.createConnection(\"\") and executes YSQL_EXTENDED_PROBE; a SQLException (endpoint not up yet, auth failure, SQL error) triggers the wrap.","commonSituations":"YSQL (5433) not yet accepting connections during startup; wrong credentials; probe table already exists causing probe DDL failure; transient connection drops.","solutions":["Inspect the wrapped SQLException cause for the root error","Increase startup timeout so early connection-refused probes can retry","Verify YSQL port and default database/credentials on the container","Ensure the probe's DROP TABLE cleanup runs (container state isn't corrupting the probe DDL)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// warm the endpoint before strict waits\nDuration timeout = Duration.ofMinutes(3);\ncontainer.waitingFor(new YugabyteDBYSQLWaitStrategy().withStartupTimeout(timeout));","typeGuard":null,"tryCatchPattern":"try { container.start(); } catch (RuntimeException e) { if (e.getCause() instanceof SQLException sqlEx) { /* inspect sqlEx for readiness/auth issue */ } }","preventionTips":["Give YSQL a generous startup timeout — it initializes slower than YCQL","Confirm YSQL credentials/database match container configuration","Watch for probe table conflicts if reusing containers"],"tags":["yugabytedb","ysql","jdbc","wait-strategy"],"backgroundTag":"connection-refused","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}