Skip to content

Commit 1ac9720

Browse files
committed
SQLException need to refresh obTable roster
1 parent 8a49a99 commit 1ac9720

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,19 @@ private static TableEntry getTableEntryFromRemote(Connection connection, TableEn
782782
}
783783
}
784784
}
785+
} catch (SQLException e) {
786+
// cannot execute sql, maybe some of the observers have been killed
787+
RUNTIME.error(LCD.convert("01-00010"), key, e.getMessage());
788+
throw new ObTableEntryRefreshException("fail to get partition location entry from remote", e, true);
785789
} catch (ObTableNotExistException e) {
786790
// avoid to refresh meta for ObTableNotExistException
787791
RUNTIME.error("getTableEntryFromRemote meet exception", e);
788792
throw e;
789793
} catch (Exception e) {
790794
RUNTIME.error(LCD.convert("01-00009"), key, e);
795+
if (e instanceof ObTableEntryRefreshException) {
796+
throw e;
797+
}
791798
throw new ObTableEntryRefreshException(format(
792799
"fail to get table entry from remote, key=%s", key), e);
793800
} finally {
@@ -897,6 +904,10 @@ public static TableEntry getTableEntryLocationFromRemote(Connection connection,
897904
ps.setString(5, key.getTableName());
898905
rs = ps.executeQuery();
899906
getPartitionLocationFromResultSetByTablet(tableEntry, rs, partitionEntry, tabletId);
907+
} catch (SQLException e) {
908+
// cannot execute sql, maybe some of the observers have been killed
909+
RUNTIME.error(LCD.convert("01-00010"), key, tableEntry, e.getMessage());
910+
throw new ObTableEntryRefreshException("fail to get partition location entry from remote", e, true);
900911
} catch (Exception e) {
901912
RUNTIME.error(LCD.convert("01-00010"), key, tableEntry, e);
902913
throw new ObTablePartitionLocationRefreshException(format(
@@ -946,6 +957,9 @@ public static TableEntry getTableEntryLocationFromRemote(Connection connection,
946957
}
947958
rs = ps.executeQuery();
948959
partitionEntry = getPartitionLocationFromResultSet(tableEntry, rs, partitionEntry);
960+
} catch (SQLException e) {
961+
RUNTIME.error(LCD.convert("01-00010"), key, partitionNum, tableEntry, e);
962+
throw new ObTableEntryRefreshException("fail to get partition location entry from remote", e, true);
949963
} catch (Exception e) {
950964
RUNTIME.error(LCD.convert("01-00010"), key, partitionNum, tableEntry, e);
951965
throw new ObTablePartitionLocationRefreshException(format(
@@ -1061,7 +1075,8 @@ public static ObIndexInfo getIndexInfoFromRemote(ObServerAddr obServerAddr, ObUs
10611075

10621076
private static void fetchFirstPart(Connection connection, TableEntry tableEntry,
10631077
ObPartFuncType obPartFuncType)
1064-
throws ObTablePartitionInfoRefreshException {
1078+
throws ObTablePartitionInfoRefreshException,
1079+
SQLException {
10651080
String tableName = "";
10661081
TableEntryKey key = tableEntry.getTableEntryKey();
10671082
if (key != null) {
@@ -1109,6 +1124,8 @@ private static void fetchFirstPart(Connection connection, TableEntry tableEntry,
11091124
tableEntry.getPartitionInfo().setPartTabletIdMap(
11101125
parseFirstPartKeyHash(rs, tableEntry));
11111126
}
1127+
} catch (SQLException e) {
1128+
throw e;
11121129
} catch (Exception e) {
11131130
RUNTIME.error(LCD.convert("01-00011"), tableEntry, obPartFuncType, e);
11141131

@@ -1131,7 +1148,8 @@ private static void fetchFirstPart(Connection connection, TableEntry tableEntry,
11311148

11321149
private static void fetchSubPart(Connection connection, TableEntry tableEntry,
11331150
ObPartFuncType subPartFuncType)
1134-
throws ObTablePartitionInfoRefreshException {
1151+
throws ObTablePartitionInfoRefreshException,
1152+
SQLException {
11351153
String tableName = "";
11361154
TableEntryKey key = tableEntry.getTableEntryKey();
11371155
if (key != null) {
@@ -1178,6 +1196,8 @@ private static void fetchSubPart(Connection connection, TableEntry tableEntry,
11781196
tableEntry.getPartitionInfo().setPartTabletIdMap(
11791197
parseSubPartKeyHash(rs, tableEntry));
11801198
}
1199+
} catch (SQLException e) {
1200+
throw e;
11811201
} catch (Exception e) {
11821202
RUNTIME.error(LCD.convert("01-00012"), tableEntry, subPartFuncType, e);
11831203
throw new ObTablePartitionInfoRefreshException(format(
@@ -1454,7 +1474,8 @@ private static ReplicaLocation buildReplicaLocation(ResultSet rs) throws SQLExce
14541474
}
14551475

14561476
private static void fetchPartitionInfo(Connection connection, TableEntry tableEntry)
1457-
throws ObTablePartitionInfoRefreshException {
1477+
throws ObTablePartitionInfoRefreshException,
1478+
SQLException {
14581479
PreparedStatement pstmt = null;
14591480
ResultSet rs = null;
14601481
ObPartitionInfo info = null;
@@ -1477,6 +1498,8 @@ private static void fetchPartitionInfo(Connection connection, TableEntry tableEn
14771498
logger.info("get part info from remote info:{}", JSON.toJSON(info));
14781499
}
14791500
tableEntry.setPartitionInfo(info);
1501+
} catch (SQLException e) {
1502+
throw e;
14801503
} catch (Exception e) {
14811504
RUNTIME.error(LCD.convert("01-00014"), tableEntry);
14821505
RUNTIME.error("fail to get part info from remote");

0 commit comments

Comments
 (0)