mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
recover fatal error
This commit is contained in:
@@ -1752,8 +1752,17 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
lastFatalErrorTimeMillis = lastErrorTimeMillis;
|
||||
onFatalError = true;
|
||||
fatalErrorCount++;
|
||||
lastFatalError = error;
|
||||
lastFatalErrorSql = sql;
|
||||
|
||||
ReentrantLock dataSourceLock = holder.getDataSource().lock;
|
||||
dataSourceLock.lock();
|
||||
try {
|
||||
emptySignal();
|
||||
} finally {
|
||||
dataSourceLock.unlock();
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@@ -2975,11 +2984,23 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
return;
|
||||
}
|
||||
|
||||
int fatalErrorIncrement = fatalErrorCount - fatalErrorCountLastShrink;
|
||||
fatalErrorCountLastShrink = fatalErrorCount;
|
||||
|
||||
final int checkCount = poolingCount - minIdle;
|
||||
final long currentTimeMillis = System.currentTimeMillis();
|
||||
for (int i = 0; i < poolingCount; ++i) {
|
||||
DruidConnectionHolder connection = connections[i];
|
||||
|
||||
if (onFatalError || fatalErrorIncrement > 0) {
|
||||
if (lastFatalErrorTimeMillis < connection.lastActiveTimeMillis) {
|
||||
keepAliveConnections[keepAliveCount++] = connection;
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkTime) {
|
||||
if (phyTimeoutMillis > 0) {
|
||||
long phyConnectTimeMillis = currentTimeMillis - connection.connectTimeMillis;
|
||||
|
||||
Reference in New Issue
Block a user