Description
LaxConnPool may assign an available connection to a new lease request even though it has pending requests already queued. Though the class makes no guarantees of fairness, it doesn't require a major change to check if there are already queued requests before attempt to allocate a connection to the new lease. This still wouldn't establish any fairness guarantee, but would improve general fairness behaviour (presuming that is a desirable thing ).
Indeed, the code already partially has such a test, only creating new pool entries to fulfill the lease if the pending queue is empty:
PoolEntry<T, C> entry = getAvailableEntry(state);
if (entry == null && pending.isEmpty()) {
entry = createPoolEntry();
The change would be just to move the pending test to prior to the entire allocation process.
This fairness does come at the price of the (small) extra expense of the pending queue test on every lease (as opposed to just some of them). It could be that it's preferable to maintain absolute maximum performance for lease when there are available connections.
Attachments
Attachments
Issue Links
- links to