Multiple threads trying to acquire a connection leads to hang
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
BoneCP |
New
|
Undecided
|
Unassigned |
Bug Description
When multiple threads all try to acquire a connection at the same time from a single partition, even if there is room in the pool to create that many connections, only some will actually get a connection. The others will be blocked until some other event (like a connection close) either releases the poll() on the free queue or wakes up the pool watch thread.
I've attached a sample program that easily demonstrates this problem. The accompanying pom.xml can be used to build it.
Near the top of the sample program, there is a constant "FAIL" set to true. If run as is, the program will hang indefinitely. If you change it to false, things work. The factors in this bug are whether the connection consumers close their connection at some point. If they don't, then things will hang, UNLESS the poolAvailabilit
With threshold at 0 and no closing - you get a hang.
Why doesn't the pool actually track the number of outstanding connection requests and create that many connections (as long as maxConnections is not exceeded)?
This appears to be a bug to me, or at the least an extremely obscure configuration requirement (the use of a non-zero availability threshold in order to avoid the hang).
maven pom file for building