mirror of
https://github.com/actiontech/dble.git
synced 2026-04-30 03:21:14 -05:00
Merge pull request #3670 from actiontech/fix/1867-1740
fix: the timing of obtaining the number of waiting threads in the connection pool is wrong
This commit is contained in:
@@ -75,9 +75,9 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
try {
|
||||
ConnectionPoolProvider.getConnGetFrenshLocekAfter();
|
||||
ConnectionPoolProvider.borrowDirectlyConnectionBefore();
|
||||
int waiting = waiters.get();
|
||||
for (PooledConnection conn : allConnections) {
|
||||
if (conn.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
|
||||
final int waiting = waiterNum;
|
||||
if (waiting > 0 && conn.getCreateByWaiter().compareAndSet(true, false)) {
|
||||
ConnectionPoolProvider.newConnectionBorrowDirectly();
|
||||
newPooledEntry(schema, waiting, true);
|
||||
@@ -97,12 +97,12 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
freshLock.readLock().lock();
|
||||
}
|
||||
try {
|
||||
final int waiting = waiterNum;
|
||||
ConnectionPoolProvider.getConnGetFrenshLocekAfter();
|
||||
ConnectionPoolProvider.borrowConnectionBefore();
|
||||
for (PooledConnection conn : allConnections) {
|
||||
if (conn.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
|
||||
// If we may have stolen another waiter's connection, request another bag add.
|
||||
final int waiting = waiterNum;
|
||||
if (waiting > 0 && conn.getCreateByWaiter().compareAndSet(true, false)) {
|
||||
ConnectionPoolProvider.newConnectionBorrow0();
|
||||
newPooledEntry(schema, waiting, true);
|
||||
|
||||
+6
-2
@@ -12,6 +12,7 @@ import com.actiontech.dble.config.Fields;
|
||||
import com.actiontech.dble.meta.ColumnMeta;
|
||||
import com.actiontech.dble.net.IOProcessor;
|
||||
import com.actiontech.dble.net.connection.BackendConnection;
|
||||
import com.actiontech.dble.net.connection.FrontendConnection;
|
||||
import com.actiontech.dble.net.connection.PooledConnection;
|
||||
import com.actiontech.dble.route.RouteResultsetNode;
|
||||
import com.actiontech.dble.services.manager.information.ManagerBaseTable;
|
||||
@@ -22,7 +23,6 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class DbleBackendConnections extends ManagerBaseTable {
|
||||
public DbleBackendConnections() {
|
||||
@@ -137,7 +137,11 @@ public final class DbleBackendConnections extends ManagerBaseTable {
|
||||
row.put("schema", c.getSchema() == null ? "NULL" : c.getSchema());
|
||||
|
||||
MySQLResponseService service = c.getBackendService();
|
||||
Optional.ofNullable(service.getSession()).ifPresent(session -> row.put("session_conn_id", session.getSource().getId() + ""));
|
||||
com.actiontech.dble.server.NonBlockingSession session = service.getSession();
|
||||
if (session != null) {
|
||||
FrontendConnection source = session.getSource();
|
||||
row.put("session_conn_id", source != null ? source.getId() + "" : "");
|
||||
}
|
||||
row.put("conn_estab_time", ((TimeUtil.currentTimeMillis() - c.getStartupTime()) / 1000) + "");
|
||||
ByteBuffer bb = c.getReadBuffer();
|
||||
row.put("conn_recv_buffer", (bb == null ? 0 : bb.capacity()) + "");
|
||||
|
||||
Reference in New Issue
Block a user