From 39fc204ad821d34d5a1ea1c63dcdd8cf5c4e8d39 Mon Sep 17 00:00:00 2001 From: JackShi148 Date: Sun, 27 Apr 2025 14:35:46 +0800 Subject: [PATCH 1/2] refresh rs list if sql exception occurs when get tenant id or ob version --- .../oceanbase/rpc/location/LocationUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java b/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java index e382e408..c6849bda 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java +++ b/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java @@ -628,6 +628,10 @@ private static String getTableNameByGroupNameFromRemote(Connection connection, T while (rs.next()) { realTableName = rs.getString("table_name"); } + } catch (SQLException e) { + RUNTIME.error("getTableNameByGroupNameFromRemote meet SQL exception", e); + throw new ObTableEntryRefreshException(format("fail to get table name from remote, key=%s", + key), e, true); } catch (ObTableNotExistException e) { // avoid to refresh meta for ObTableNotExistException RUNTIME.error("getTableNameByGroupNameFromRemote meet exception", e); @@ -672,7 +676,8 @@ TableEntry execute(Connection connection) throws ObTableEntryRefreshException { private static void getObVersionFromRemote(final Connection connection) throws ObTableEntryRefreshException, - FeatureNotSupportedException { + FeatureNotSupportedException, + SQLException { PreparedStatement ps = null; ResultSet rs = null; try { @@ -684,6 +689,8 @@ private static void getObVersionFromRemote(final Connection connection) } else { throw new ObTableEntryRefreshException("fail to get ob version from remote"); } + } catch (SQLException e) { + throw e; } catch (FeatureNotSupportedException e) { throw e; } catch (Exception e) { @@ -704,7 +711,8 @@ private static void getObVersionFromRemote(final Connection connection) // check tenant exist or not private static int checkTenantExistFromRemote(final Connection connection, TableEntryKey key) - throws ObTableEntryRefreshException { + throws ObTableEntryRefreshException, + SQLException { try (PreparedStatement ps = connection.prepareStatement(OB_TENANT_EXIST_SQL)) { ps.setString(1, key.getTenantName()); try (ResultSet rs = ps.executeQuery()) { @@ -713,9 +721,13 @@ private static int checkTenantExistFromRemote(final Connection connection, Table } else { return rs.getInt("tenant_id"); } + } catch(SQLException e) { + throw e; } catch (Exception e) { throw new ObTableEntryRefreshException("fail to get tenant id from remote", e); } + } catch (SQLException e) { + throw e; } catch (Exception e) { throw new ObTableEntryRefreshException("fail to get tenant id from remote", e); } From 42702f426b14019c6fba4f2201bf101509e0f017 Mon Sep 17 00:00:00 2001 From: JackShi148 Date: Sun, 27 Apr 2025 16:40:59 +0800 Subject: [PATCH 2/2] retry when ob trans timeout --- .../com/alipay/oceanbase/rpc/exception/ObTableException.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alipay/oceanbase/rpc/exception/ObTableException.java b/src/main/java/com/alipay/oceanbase/rpc/exception/ObTableException.java index ccd52fb6..0f7f9ee0 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/exception/ObTableException.java +++ b/src/main/java/com/alipay/oceanbase/rpc/exception/ObTableException.java @@ -87,7 +87,8 @@ public boolean isNeedRefreshTableEntry() { public boolean isNeedRetryError() { return errorCode == ResultCodes.OB_TRY_LOCK_ROW_CONFLICT.errorCode || errorCode == ResultCodes.OB_TRANSACTION_SET_VIOLATION.errorCode - || errorCode == ResultCodes.OB_SCHEMA_EAGAIN.errorCode; + || errorCode == ResultCodes.OB_SCHEMA_EAGAIN.errorCode + || errorCode == ResultCodes.OB_TRANS_TIMEOUT.errorCode; } }