Skip to content

Commit 9acf101

Browse files
committed
Force wait queue handler to wake up every time a request is queue
JAVA-3400
1 parent bc76708 commit 9acf101

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ protected synchronized void updateDescription(final ClusterDescription newDescri
255255
}
256256

257257
description = newDescription;
258-
phase.getAndSet(new CountDownLatch(1)).countDown();
258+
updatePhase();
259259
}
260260

261261
protected void fireChangeEvent(final ClusterDescriptionChangedEvent event) {
@@ -267,6 +267,10 @@ public ClusterDescription getCurrentDescription() {
267267
return description;
268268
}
269269

270+
private synchronized void updatePhase() {
271+
phase.getAndSet(new CountDownLatch(1)).countDown();
272+
}
273+
270274
private long getMaxWaitTimeNanos() {
271275
if (settings.getServerSelectionTimeout(NANOSECONDS) < 0) {
272276
return Long.MAX_VALUE;
@@ -463,6 +467,8 @@ private synchronized void notifyWaitQueueHandler(final ServerSelectionRequest re
463467
waitQueueHandler = new Thread(new WaitQueueHandler(), "cluster-" + clusterId.getValue());
464468
waitQueueHandler.setDaemon(true);
465469
waitQueueHandler.start();
470+
} else {
471+
updatePhase();
466472
}
467473
}
468474
}

0 commit comments

Comments
 (0)