@@ -244,8 +244,10 @@ A concept that represents pending requests for [Connections](#connection). When
244
244
either receives a [ Connection] ( #connection ) or times out. A WaitQueue has the following traits:
245
245
246
246
- ** Thread-Safe** : When multiple threads attempt to enter or exit a WaitQueue, they do so in a thread-safe manner.
247
- - ** Ordered/Fair** : When [ Connections] ( #connection ) are made available, they are issued out to threads in the order that
248
- the threads entered the WaitQueue.
247
+ - ** Ordered/fair** : When [ Connections] ( #connection ) are made available, they SHOULD be issued out to threads in the
248
+ order that the threads entered the WaitQueue. If this is behavior poses too much of an implementation burden, then
249
+ at the very least threads that have entered the queue more recently MUST NOT be intentionally prioritized over those
250
+ that entered it earlier.
249
251
- ** Timeout aggressively:** Members of a WaitQueue MUST timeout if they are enqueued for longer than the computed
250
252
timeout and MUST leave the WaitQueue immediately in this case.
251
253
@@ -557,7 +559,7 @@ MUST wait to service the request until neither of those two conditions are met o
557
559
becomes available, re-entering the checkOut loop in either case. This waiting MUST NOT prevent
558
560
[ Connections] ( #connection ) from being checked into the pool. Additionally, the Pool MUST NOT service any newer checkOut
559
561
requests before fulfilling the original one which could not be fulfilled. For drivers that implement the WaitQueue via a
560
- fair semaphore, a condition variable may also be needed to to meet this requirement. Waiting on the condition variable
562
+ fair semaphore, a condition variable may also be needed to meet this requirement. Waiting on the condition variable
561
563
SHOULD also be limited by the WaitQueueTimeout, if the driver supports one and it was specified by the user.
562
564
563
565
If the pool is "closed" or "paused", any attempt to check out a [ Connection] ( #connection ) MUST throw an Error. The error
@@ -1258,12 +1260,11 @@ These options were originally only implemented in three drivers (Java, C#, and P
1258
1260
these fields would allow for faster diagnosis of issues in the connection pool, they would not actually prevent an error
1259
1261
from occurring.
1260
1262
1261
- Additionally, these options have the effect of prioritizing older requests over newer requests, which is not necessarily
1262
- the behavior that users want. They can also result in cases where queue access oscillates back and forth between full
1263
- and not full. If a driver has a full waitQueue, then all requests for [ Connections] ( #connection ) will be rejected. If
1264
- the client is continually spammed with requests, you could wind up with a scenario where as soon as the waitQueue is no
1265
- longer full, it is immediately filled. It is not a favorable situation to be in, partially b/c it violates the fairness
1266
- guarantee that the waitQueue normally provides.
1263
+ Additionally, these options have the effect of prioritizing newer requests over older requests, which is not necessarily
1264
+ the behavior that users want. For example, consider a situation when a WaitQueue is full, and a request for
1265
+ [ Connection] ( #connection ) gets rejected. Then a spot opens in the WaitQueue, and a newer request gets accepted. One may
1266
+ say that the newer request was prioritized over the older one, which violates the fairness recommendation that the
1267
+ WaitQueue normally adheres to.
1267
1268
1268
1269
Because of these issues, it does not make sense to
1269
1270
[ go against driver mantras and provide an additional knob] ( ../driver-mantras.md# ) . We may eventually pursue an
@@ -1374,6 +1375,8 @@ to close and remove from its pool a [Connection](#connection) which has unread e
1374
1375
1375
1376
## Changelog
1376
1377
1378
+ - 2024-11-27: Relaxed the WaitQueue fairness requirement.
1379
+
1377
1380
- 2024-11-01: Fixed race condition in pool-checkout-returned-connection-maxConnecting.yml test.
1378
1381
1379
1382
- 2024-01-23: Migrated from reStructuredText to Markdown.
0 commit comments