Merge pull request #196 from xiaoaiaxss/expire_fix

fix issue #195
This commit is contained in:
DingZhen 2024-09-23 18:04:46 +08:00 committed by GitHub
commit 93181fbb0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -759,10 +759,16 @@ public class ObTable extends AbstractObTable implements Lifecycle {
* 4. Attempt to reconnect the marked connections.
**/
private void checkAndReconnect() {
// do nothing when there is only 1 connection
if (obTableConnectionPoolSize == 1) {
return;
}
// Iterate over the connection pool to identify connections that have expired
List<Integer> expiredConnIds = new ArrayList<>();
long num = turn.get();
for (int i = 1; i <= obTableConnectionPoolSize; ++i) {
int idx = (int) ((i + turn.get()) % obTableConnectionPoolSize);
int idx = (int) ((i + num) % obTableConnectionPoolSize);
if (connectionPool[idx].checkExpired()) {
expiredConnIds.add(idx);
}