{"record":{"id":"ab85ea8bbf6def52","repo":"apache/shardingsphere","slug":"13000","errorCode":"13000","errorMessage":"Can not get %d connections one time, partition succeed connection(%d) have released. Please consider increasing the 'maxPoolSize' of the data sources or decreasing the 'max-connections-size-per-query' in properties.","messagePattern":"Can not get (.+?) connections one time, partition succeed connection\\((.+?)\\) have released\\. Please consider increasing the 'maxPoolSize' of the data sources or decreasing the 'max-connections-size-per-query' in properties\\.","errorType":"exception","errorClass":"OverallConnectionNotEnoughException","httpStatus":null,"severity":"error","filePath":"proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/datasource/JDBCBackendDataSource.java","lineNumber":73,"sourceCode":"        if (ConnectionMode.CONNECTION_STRICTLY == connectionMode) {\n            return createConnections(databaseName, dataSourceName, dataSource, connectionSize);\n        }\n        synchronized (dataSource) {\n            return createConnections(databaseName, dataSourceName, dataSource, connectionSize);\n        }\n    }\n    \n    private List<Connection> createConnections(final String databaseName, final String dataSourceName,\n                                               final DataSource dataSource, final int connectionSize) throws SQLException {\n        List<Connection> result = new ArrayList<>(connectionSize);\n        for (int i = 0; i < connectionSize; i++) {\n            try {\n                result.add(createConnection(databaseName, dataSourceName, dataSource));\n            } catch (final SQLException ex) {\n                for (Connection each : result) {\n                    each.close();\n                }\n                throw new OverallConnectionNotEnoughException(connectionSize, result.size(), ex);\n            }\n        }\n        return result;\n    }\n    \n    private Connection createConnection(final String databaseName, final String dataSourceName, final DataSource dataSource) throws SQLException {\n        TransactionRule transactionRule = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(TransactionRule.class);\n        ShardingSphereDistributedTransactionManager distributedTransactionManager = transactionRule.getResource().getTransactionManager(transactionRule.getDefaultType());\n        Connection result = isInDistributedTransaction(distributedTransactionManager) ? distributedTransactionManager.getConnection(databaseName, dataSourceName) : dataSource.getConnection();\n        if (dataSourceName.contains(\".\")) {\n            String catalog = dataSourceName.split(\"\\\\.\")[1];\n            result.setCatalog(catalog);\n        }\n        return result;\n    }\n    \n    private boolean isInDistributedTransaction(final ShardingSphereDistributedTransactionManager distributedTransactionManager) {\n        return null != distributedTransactionManager && distributedTransactionManager.isInTransaction();","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/datasource/JDBCBackendDataSource.java#L55-L91","documentation":"OverallConnectionNotEnoughException (error code 13000) is thrown by JDBCBackendDataSource.createConnections when the proxy tries to acquire `connectionSize` connections from one storage DataSource for a single query and any acquisition fails partway. Every already-obtained connection is closed and the partial failure is rethrown with this message, so the query never runs with fewer connections than the routing plan requires. The root cause is the wrapped SQLException: typically the pool (maxPoolSize) or the backend database itself refusing the Nth simultaneous connection.","triggerScenarios":"A single sharded/routed SQL statement that fans out to more connections than `max-connections-size-per-query` allows per query against a pool whose `maxPoolSize` is smaller, or when the backend DB rejects a new connection (max_connections reached, pool timeout). Concretely: createConnections() loops i < connectionSize calling dataSource.getConnection(); any SQLException on iteration i closes the previous i connections and throws OverallConnectionNotEnoughException(connectionSize, result.size(), ex).","commonSituations":"Default maxPoolSize (e.g. HikariCP) left low while max-connections-size-per-query is 8 or higher; a burst of concurrent proxy queries exhausting backend max_connections; a slow/unavailable storage node causing pool acquisition timeouts during high load; migration to larger sharding counts increasing fan-out per query.","solutions":["Increase `maxPoolSize` (and pool `maximumPoolSize` for Hikari) on the affected storage unit so maxPoolSize >= max-connections-size-per-query times expected concurrent queries","Lower `max-connections-size-per-query` in server.yaml props (e.g. from 8 to 2 or 1) so each query needs fewer simultaneous connections","Inspect the cause chain of the thrown exception (getCause()) to confirm whether it is a pool timeout, auth failure, or backend max_connections limit, and raise the backend limit if that is the ceiling","Check for connection leaks or long-running transactions holding pool connections, which shrink the effective pool available per query"],"exampleFix":"# before (server.yaml / storage unit)\nstorageUnits:\n  ds_0:\n    pool:\n      maxPoolSize: 2\nprops:\n  max-connections-size-per-query: 8\n\n# after\nstorageUnits:\n  ds_0:\n    pool:\n      maxPoolSize: 20\nprops:\n  max-connections-size-per-query: 2","handlingStrategy":"retry","validationCode":"// before issuing a fan-out query, confirm pool capacity >= per-query demand\nint perQuery = metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);\nHikariDataSource ds = (HikariDataSource) dataSource; // per storage unit\nif (ds.getMaximumPoolSize() < perQuery) {\n    throw new IllegalStateException(\"maxPoolSize (\" + ds.getMaximumPoolSize()\n            + \") < max-connections-size-per-query (\" + perQuery + \"); query will fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    List<QueryResult> rows = backendDataSource.getConnections(databaseName, dataSourceName, connectionSize);\n} catch (final OverallConnectionNotEnoughException ex) {\n    log.error(\"Need {} connections, got {} before failure; cause: {}\",\n            ex.getNeeded(), ex.getAcquired(), ex.getCause()); // adjust accessors to actual API\n    // capacity problem: adjust maxPoolSize / max-connections-size-per-query, then retry once after backoff\n}","preventionTips":["Capacity-plan maxPoolSize >= max-connections-size-per-query * expected concurrent queries per storage unit","Monitor backend max_connections and pool wait times; alert before saturation","Keep transactions short so pool connections are returned quickly during fan-out queries"],"tags":["connection-pool","jdbc","proxy","configuration","capacity"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}