Skip to content

Commit 9553c77

Browse files
committed
fix: the timing of obtaining the number of waiting threads in the connection pool is wrong
1 parent 4f1326d commit 9553c77

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/actiontech/dble/backend/pool/ConnectionPool.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ public PooledConnection borrowDirectly(final String schema) {
8080
try {
8181
ConnectionPoolProvider.getConnGetFrenshLocekAfter();
8282
ConnectionPoolProvider.borrowDirectlyConnectionBefore();
83-
int waiting = waiters.get();
8483
for (PooledConnection conn : allConnections) {
8584
if (conn.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
85+
final int waiting = waiterNum;
86+
ConnectionPoolProvider.getWaiterCountAfter();
8687
if (waiting > 0 && conn.getCreateByWaiter().compareAndSet(true, false)) {
8788
ConnectionPoolProvider.newConnectionBorrowDirectly();
8889
newPooledEntry(schema, waiting, true);
@@ -102,12 +103,12 @@ public PooledConnection borrow(final String schema, long timeout, final TimeUnit
102103
freshLock.readLock().lock();
103104
}
104105
try {
105-
final int waiting = waiterNum;
106106
ConnectionPoolProvider.getConnGetFrenshLocekAfter();
107107
ConnectionPoolProvider.borrowConnectionBefore();
108108
for (PooledConnection conn : allConnections) {
109109
if (conn.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
110110
// If we may have stolen another waiter's connection, request another bag add.
111+
final int waiting = waiterNum;
111112
if (waiting > 0 && conn.getCreateByWaiter().compareAndSet(true, false)) {
112113
ConnectionPoolProvider.newConnectionBorrow0();
113114
newPooledEntry(schema, waiting, true);

src/main/java/com/actiontech/dble/btrace/provider/ConnectionPoolProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,9 @@ public static void fillPool() {
5151

5252
}
5353

54+
public static void getWaiterCountAfter() {
55+
56+
}
57+
5458

5559
}

0 commit comments

Comments
 (0)