Skip to content

Commit 774a4af

Browse files
authored
Retry ob trans timeout and SQL exception (#329)
* refresh rs list if sql exception occurs when get tenant id or ob version * retry when ob trans timeout
1 parent 420a067 commit 774a4af

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/main/java/com/alipay/oceanbase/rpc/exception/ObTableException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public boolean isNeedRefreshTableEntry() {
8787
public boolean isNeedRetryError() {
8888
return errorCode == ResultCodes.OB_TRY_LOCK_ROW_CONFLICT.errorCode
8989
|| errorCode == ResultCodes.OB_TRANSACTION_SET_VIOLATION.errorCode
90-
|| errorCode == ResultCodes.OB_SCHEMA_EAGAIN.errorCode;
90+
|| errorCode == ResultCodes.OB_SCHEMA_EAGAIN.errorCode
91+
|| errorCode == ResultCodes.OB_TRANS_TIMEOUT.errorCode;
9192
}
9293

9394
}

src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ private static String getTableNameByGroupNameFromRemote(Connection connection, T
628628
while (rs.next()) {
629629
realTableName = rs.getString("table_name");
630630
}
631+
} catch (SQLException e) {
632+
RUNTIME.error("getTableNameByGroupNameFromRemote meet SQL exception", e);
633+
throw new ObTableEntryRefreshException(format("fail to get table name from remote, key=%s",
634+
key), e, true);
631635
} catch (ObTableNotExistException e) {
632636
// avoid to refresh meta for ObTableNotExistException
633637
RUNTIME.error("getTableNameByGroupNameFromRemote meet exception", e);
@@ -672,7 +676,8 @@ TableEntry execute(Connection connection) throws ObTableEntryRefreshException {
672676

673677
private static void getObVersionFromRemote(final Connection connection)
674678
throws ObTableEntryRefreshException,
675-
FeatureNotSupportedException {
679+
FeatureNotSupportedException,
680+
SQLException {
676681
PreparedStatement ps = null;
677682
ResultSet rs = null;
678683
try {
@@ -684,6 +689,8 @@ private static void getObVersionFromRemote(final Connection connection)
684689
} else {
685690
throw new ObTableEntryRefreshException("fail to get ob version from remote");
686691
}
692+
} catch (SQLException e) {
693+
throw e;
687694
} catch (FeatureNotSupportedException e) {
688695
throw e;
689696
} catch (Exception e) {
@@ -704,7 +711,8 @@ private static void getObVersionFromRemote(final Connection connection)
704711

705712
// check tenant exist or not
706713
private static int checkTenantExistFromRemote(final Connection connection, TableEntryKey key)
707-
throws ObTableEntryRefreshException {
714+
throws ObTableEntryRefreshException,
715+
SQLException {
708716
try (PreparedStatement ps = connection.prepareStatement(OB_TENANT_EXIST_SQL)) {
709717
ps.setString(1, key.getTenantName());
710718
try (ResultSet rs = ps.executeQuery()) {
@@ -713,9 +721,13 @@ private static int checkTenantExistFromRemote(final Connection connection, Table
713721
} else {
714722
return rs.getInt("tenant_id");
715723
}
724+
} catch(SQLException e) {
725+
throw e;
716726
} catch (Exception e) {
717727
throw new ObTableEntryRefreshException("fail to get tenant id from remote", e);
718728
}
729+
} catch (SQLException e) {
730+
throw e;
719731
} catch (Exception e) {
720732
throw new ObTableEntryRefreshException("fail to get tenant id from remote", e);
721733
}

0 commit comments

Comments
 (0)