{"record":{"id":"b4a582e1aaf2871a","repo":"apache/shardingsphere","slug":"0-b4a582","errorCode":"0","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":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java","lineNumber":401,"sourceCode":"        }\n        synchronized (dataSource) {\n            return createConnections(databaseName, dataSourceName, dataSource, connectionSize, connectionContext.getTransactionContext());\n        }\n    }\n    \n    private List<Connection> createConnections(final String databaseName, final String dataSourceName, final DataSource dataSource, final int connectionSize,\n                                               final TransactionConnectionContext transactionConnectionContext) throws SQLException {\n        List<Connection> result = new ArrayList<>(connectionSize);\n        for (int i = 0; i < connectionSize; i++) {\n            try {\n                Connection connection = createConnection(databaseName, dataSourceName, dataSource, transactionConnectionContext);\n                methodInvocationRecorder.replay(connection);\n                result.add(connection);\n            } catch (final SQLException ex) {\n                for (Connection each : result) {\n                    each.close();\n                }\n                throw new OverallConnectionNotEnoughException(connectionSize, result.size(), ex).toSQLException();\n            }\n        }\n        return result;\n    }\n    \n    private Connection createConnection(final String databaseName, final String dataSourceName, final DataSource dataSource,\n                                        final TransactionConnectionContext transactionConnectionContext) throws SQLException {\n        Optional<Connection> connectionInTransaction = getConnectionTransaction().getConnection(databaseName, dataSourceName, transactionConnectionContext);\n        return connectionInTransaction.isPresent() ? connectionInTransaction.get() : dataSource.getConnection();\n    }\n    \n    @Override\n    public void close() throws SQLException {\n        clearCachedConnections();\n    }\n}\n","sourceCodeStart":383,"sourceCodeEnd":418,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java#L383-L418","documentation":"OverallConnectionNotEnoughException (converted to SQLException) thrown by DriverDatabaseConnectionManager.createConnections when it cannot obtain the requested number of connections from a datasource. Any SQLException from dataSource.getConnection() aborts the loop: all connections already acquired in this batch are closed (partition success released) and the aggregate error is thrown. The message tells you the two knobs: raise the pool's maxPoolSize or lower ShardingSphere's max-connections-size-per-query.","triggerScenarios":"A single query routed to many tables/shards needs connectionSize connections from one datasource, and the pool is exhausted or the DB refuses new connections mid-batch (maxPoolSize reached, DB max_connections hit, network failure).","commonSituations":"High sharding counts with default pool sizes (each query may need several connections per shard); OLAP/large result queries over many shards; concurrent queries exceeding HikariCP maximumPoolSize; DB-side connection limits; long transactions holding pool connections.","solutions":["Increase the underlying datasource pool size (e.g. HikariCP maximumPoolSize) so connectionSize per query can be satisfied.","Lower max-connections-size-per-query in ShardingSphere props so a query reuses fewer connections per shard (memory restriction mode).","Reduce concurrent heavy queries or shard count involved per statement.","Check DB-side max_connections and network health if the underlying getConnection error indicates refusal rather than pool exhaustion."],"exampleFix":"# before\nprops:\n  max-connections-size-per-query: 8 # too high for pool size 10 with 4 shards\ndatasource:\n  ds_0: maxPoolSize: 10\n# after\nprops:\n  max-connections-size-per-query: 2\ndatasource:\n  ds_0: maximumPoolSize: 32","handlingStrategy":"validation","validationCode":"int poolMax = hikariConfig.getMaximumPoolSize();\nint perQuery = configuredMaxConnectionsPerQuery;\nif (shardCount * perQuery > poolMax) warn(\"pool too small\");","typeGuard":null,"tryCatchPattern":"catch (SQLException ex) { if (ex.getMessage().contains(\"maxPoolSize\")) adjustPoolOrThrottle(); rethrow; }","preventionTips":["Size maxPoolSize >= shard count x max-connections-size-per-query (for strict mode)","Lower max-connections-size-per-query for wide OLAP queries","Monitor pool utilization before peak load","Watch DB max_connections limits"],"tags":["jdbc","connection-pool","capacity","sharding"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}