From b0ad9eab23368b7e8f28a42fa821759ce3613926 Mon Sep 17 00:00:00 2001 From: JackShi148 Date: Fri, 9 May 2025 11:42:52 +0800 Subject: [PATCH] do not retry any other errors and do not impact exception type thrown --- .../impl/execute/query/AbstractQueryStreamResult.java | 11 +++++++---- .../stream/ObTableClientQueryAsyncStreamResult.java | 6 +++--- .../rpc/table/ObTableClientBatchOpsImpl.java | 5 ++--- .../rpc/table/ObTableClientLSBatchOpsImpl.java | 5 ++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/AbstractQueryStreamResult.java b/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/AbstractQueryStreamResult.java index 0066024e..253e5593 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/AbstractQueryStreamResult.java +++ b/src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/AbstractQueryStreamResult.java @@ -191,8 +191,7 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger, } else { logger.warn("meet exception when execute in odp mode." + "tablename: {}, errMsg: {}", indexTableName, e.getMessage()); - // odp mode do not retry any other exceptions - throw new ObTableException(e); + throw e; } } else { needRefreshPartitionLocation = true; @@ -370,7 +369,7 @@ public boolean next() throws Exception { break; } catch (Exception e) { - if (e instanceof ObTableNeedFetchMetaException) { + if (shouldRetry(e)) { // TODO: need to skip over the partitions that have been scanned setExpectant(refreshPartition(tableQuery, tableName)); // Reset the iterator to start over @@ -574,6 +573,10 @@ protected void cacheStreamNext(ObPair partIdWithObTable, } } + protected boolean shouldRetry(Throwable t) { + return !client.isOdpMode() && t instanceof ObTableNeedFetchMetaException; + } + /** * Get row. */ @@ -612,7 +615,7 @@ public void init() throws Exception { // try access new partition, async will not remove useless expectant referToNewPartition(entry.getValue()); } catch (Exception e) { - if (e instanceof ObTableNeedFetchMetaException) { + if (shouldRetry(e)) { resetCachedResult(); setExpectant(refreshPartition(tableQuery, tableName)); it = expectant.entrySet().iterator(); diff --git a/src/main/java/com/alipay/oceanbase/rpc/stream/ObTableClientQueryAsyncStreamResult.java b/src/main/java/com/alipay/oceanbase/rpc/stream/ObTableClientQueryAsyncStreamResult.java index 158de181..690435dd 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/stream/ObTableClientQueryAsyncStreamResult.java +++ b/src/main/java/com/alipay/oceanbase/rpc/stream/ObTableClientQueryAsyncStreamResult.java @@ -76,7 +76,7 @@ public void init() throws Exception { referToNewPartition(firstEntry.getValue()); break; } catch (Exception e) { - if (e instanceof ObTableNeedFetchMetaException) { + if (shouldRetry(e)) { setExpectant(refreshPartition(this.asyncRequest.getObTableQueryRequest() .getTableQuery(), client.getPhyTableNameFromTableGroup(entityType, tableName))); @@ -232,7 +232,7 @@ public boolean next() throws Exception { // try access new partition, async will not remove useless expectant referToLastStreamResult(lastEntry.getValue()); } catch (Exception e) { - if (e instanceof ObTableNeedFetchMetaException) { + if (shouldRetry(e)) { String realTableName = client.getPhyTableNameFromTableGroup(entityType, tableName); TableEntry entry = client.getOrRefreshTableEntry(realTableName, false); @@ -272,7 +272,7 @@ public boolean next() throws Exception { // try access new partition, async will not remove useless expectant referToNewPartition(entry.getValue()); } catch (Exception e) { - if (e instanceof ObTableNeedFetchMetaException) { + if (shouldRetry(e)) { String realTableName = client.getPhyTableNameFromTableGroup(entityType, tableName); TableEntry tableEntry = client.getOrRefreshTableEntry(realTableName, false); diff --git a/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientBatchOpsImpl.java b/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientBatchOpsImpl.java index b11f5655..698d11d0 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientBatchOpsImpl.java +++ b/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientBatchOpsImpl.java @@ -399,8 +399,7 @@ public void partitionExecute(ObTableOperationResult[] results, } else { logger.warn("meet exception when execute normal batch in odp mode." + "tablename: {}, errMsg: {}", tableName, ex.getMessage()); - // odp mode do not retry any other exceptions - throw new ObTableException(ex); + throw ex; } } else if (ex instanceof ObTableReplicaNotReadableException) { if (System.currentTimeMillis() - startExecute < obTableClient @@ -544,7 +543,7 @@ public void partitionExecute(ObTableOperationResult[] results, } private boolean shouldRetry(Throwable throwable) { - return throwable instanceof ObTableNeedFetchMetaException; + return !obTableClient.isOdpMode() && throwable instanceof ObTableNeedFetchMetaException; } private void executeWithRetries(ObTableOperationResult[] results, Map.Entry>>> entry) throws Exception { diff --git a/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java b/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java index b061ccad..4cd8899b 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java +++ b/src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java @@ -659,8 +659,7 @@ public void partitionExecute(ObTableSingleOpResult[] results, } else { logger.warn("meet exception when execute ls batch in odp mode." + "tablename: {}, errMsg: {}", realTableName, ex.getMessage()); - // odp mode do not retry any other exceptions - throw new ObTableException(ex); + throw ex; } } else if (ex instanceof ObTableReplicaNotReadableException) { if (System.currentTimeMillis() - startExecute < obTableClient.getRuntimeMaxWait()) { @@ -823,7 +822,7 @@ public void partitionExecute(ObTableSingleOpResult[] results, } private boolean shouldRetry(Throwable throwable) { - return throwable instanceof ObTableNeedFetchMetaException; + return !obTableClient.isOdpMode() && throwable instanceof ObTableNeedFetchMetaException; } private void executeWithRetries(ObTableSingleOpResult[] results,