Skip to content

Commit 93181fb

Browse files
authored
Merge pull request #196 from xiaoaiaxss/expire_fix
fix issue #195
2 parents 28b9dec + fef6ef9 commit 93181fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/alipay/oceanbase/rpc/table/ObTable.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,16 @@ public ObTableConnection getConnection() {
759759
* 4. Attempt to reconnect the marked connections.
760760
**/
761761
private void checkAndReconnect() {
762+
// do nothing when there is only 1 connection
763+
if (obTableConnectionPoolSize == 1) {
764+
return;
765+
}
766+
762767
// Iterate over the connection pool to identify connections that have expired
763768
List<Integer> expiredConnIds = new ArrayList<>();
769+
long num = turn.get();
764770
for (int i = 1; i <= obTableConnectionPoolSize; ++i) {
765-
int idx = (int) ((i + turn.get()) % obTableConnectionPoolSize);
771+
int idx = (int) ((i + num) % obTableConnectionPoolSize);
766772
if (connectionPool[idx].checkExpired()) {
767773
expiredConnIds.add(idx);
768774
}

0 commit comments

Comments
 (0)