mirror of
https://github.com/actiontech/dble.git
synced 2026-05-03 13:00:17 -05:00
fix: use the state value before restoration to judge
This commit is contained in:
@@ -206,7 +206,7 @@ public class MySQLHeartbeat {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("heartbeat to [" + source.getConfig().getUrl() + "] setOK");
|
||||
}
|
||||
|
||||
MySQLHeartbeatStatus previousStatus = status;
|
||||
switch (status) {
|
||||
case TIMEOUT:
|
||||
this.status = MySQLHeartbeatStatus.INIT;
|
||||
@@ -231,8 +231,8 @@ public class MySQLHeartbeat {
|
||||
AlertUtil.alertResolve(AlarmCode.HEARTBEAT_FAIL, Alert.AlertLevel.WARN, "mysql", this.source.getConfig().getId(), labels);
|
||||
}
|
||||
//after the heartbeat changes from failure to success, it needs to be expanded immediately
|
||||
if (source.getTotalConnections() == 0 && !status.equals(MySQLHeartbeatStatus.INIT) && !status.equals(MySQLHeartbeatStatus.OK)) {
|
||||
LOGGER.debug("[updatePoolCapacity] heartbeat to [{}] setOk, previous status is {}", source, status);
|
||||
if (source.getTotalConnections() == 0 && !previousStatus.equals(MySQLHeartbeatStatus.INIT) && !previousStatus.equals(MySQLHeartbeatStatus.OK)) {
|
||||
LOGGER.debug("[updatePoolCapacity] heartbeat to [{}] setOk, previous status is {}", source, previousStatus);
|
||||
source.updatePoolCapacity();
|
||||
}
|
||||
if (isStop) {
|
||||
|
||||
@@ -80,10 +80,12 @@ 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)) {
|
||||
if (waiting > 0 && conn.getCreateByWaiter().compareAndSet(true, false)) {
|
||||
ConnectionPoolProvider.newConnectionBorrowDirectly();
|
||||
newPooledEntry(schema, waiting, true);
|
||||
}
|
||||
return conn;
|
||||
@@ -108,6 +110,7 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
if (conn.compareAndSet(STATE_NOT_IN_USE, STATE_IN_USE)) {
|
||||
// If we may have stolen another waiter's connection, request another bag add.
|
||||
if (waiting > 0 && conn.getCreateByWaiter().compareAndSet(true, false)) {
|
||||
ConnectionPoolProvider.newConnectionBorrow0();
|
||||
newPooledEntry(schema, waiting, true);
|
||||
}
|
||||
return conn;
|
||||
@@ -116,6 +119,7 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
|
||||
waiterNum = waiters.incrementAndGet();
|
||||
try {
|
||||
ConnectionPoolProvider.newConnectionBorrow1();
|
||||
newPooledEntry(schema, waiterNum, true);
|
||||
|
||||
ConnectionPoolProvider.newConnectionAfter();
|
||||
@@ -200,6 +204,7 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
if (LOGGER.isDebugEnabled() && connectionsToAdd > 0) {
|
||||
LOGGER.debug("need add {}", connectionsToAdd);
|
||||
}
|
||||
ConnectionPoolProvider.fillPool();
|
||||
for (int i = 0; i < connectionsToAdd; i++) {
|
||||
// newPooledEntry(schemas[i % schemas.length]);
|
||||
newPooledEntry(null, 1, false);
|
||||
|
||||
@@ -26,9 +26,30 @@ public final class ConnectionPoolProvider {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void newConnectionBorrowDirectly() {
|
||||
|
||||
}
|
||||
|
||||
public static void newConnectionBorrow0() {
|
||||
|
||||
}
|
||||
|
||||
public static void newConnectionBorrow1() {
|
||||
|
||||
}
|
||||
|
||||
public static void borrowConnectionBefore() {
|
||||
|
||||
}
|
||||
|
||||
public static void borrowDirectlyConnectionBefore() {
|
||||
|
||||
}
|
||||
|
||||
public static void fillPool() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user