Skip to content

Commit 1589ccc

Browse files
committed
Recalculate maxQueueSize based on shards count
Currently maxQueueSize is 256 by default. Problem is that some hosts can have 1 shard, others can have 256 shards. While having cap of 256 pending requests for 1 shard host is ok. For host of 256 shards it is way to low. This commit scales maxQueueSize by number of shards, which allow default value works for hosts of any size.
1 parent ad4ff1c commit 1589ccc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ ListenableFuture<Connection> borrowConnection(
514514

515515
int shardId = 0;
516516
if (host.getShardingInfo() != null) {
517+
maxQueueSize = host.getShardingInfo().getShardsCount() * maxQueueSize;
517518
if (routingKey != null) {
518519
Metadata metadata = manager.cluster.getMetadata();
519520
Token t = metadata.newToken(partitioner, routingKey);

driver-core/src/main/java/com/datastax/driver/core/PoolingOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,8 @@ public PoolingOptions setPoolTimeoutMillis(int poolTimeoutMillis) {
462462
}
463463

464464
/**
465-
* Returns the maximum number of requests that get enqueued if no connection is available.
465+
* Returns the maximum number of requests per shard that get enqueued if no connection is
466+
* available.
466467
*
467468
* @return the maximum queue size.
468469
*/

0 commit comments

Comments
 (0)