Skip to content

Commit bd6e7ff

Browse files
committed
use runtimeMaxWait to replace tryTimes in async stream result
1 parent 1d74b96 commit bd6e7ff

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,8 +1493,8 @@ private static ObPartitionEntry getPartitionLocationFromResultSetByTablet(TableE
14931493
if (ObGlobal.isSchemaVersionSupport()) {
14941494
long curSchemaVersion = rs.getLong("schema_version");
14951495
String errMsg = "getPartitionLocationFromResultSetByTablet schema_version does not match for table: " + tableEntry.getTableEntryKey().getTableName()
1496-
+ ", exist version: " + schemaVersion
1497-
+ ", new version: " + curSchemaVersion;
1496+
+ ", exist version: " + schemaVersion
1497+
+ ", new version: " + curSchemaVersion;
14981498
checkSchemaVersionMatch(schemaVersion, curSchemaVersion, errMsg);
14991499
}
15001500
ReplicaLocation replica = buildReplicaLocation(rs);

src/main/java/com/alipay/oceanbase/rpc/location/model/TableRoute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public ObTable getFirstObTable() {
159159

160160
public ObTableServerCapacity getServerCapacity() {
161161
if (tableClient.isOdpMode()) {
162-
if (odpInfo.getObTable() == null) {
162+
if (odpInfo == null || odpInfo.getObTable() == null) {
163163
throw new IllegalStateException("client is not initialized and obTable is empty");
164164
}
165165
return odpInfo.getObTable().getServerCapacity();

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/query/AbstractQueryStreamResult.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package com.alipay.oceanbase.rpc.protocol.payload.impl.execute.query;
1919

20-
import com.alipay.oceanbase.rpc.ObGlobal;
2120
import com.alipay.oceanbase.rpc.ObTableClient;
2221
import com.alipay.oceanbase.rpc.bolt.transport.ObTableConnection;
2322
import com.alipay.oceanbase.rpc.bolt.transport.TransportCodes;

src/main/java/com/alipay/oceanbase/rpc/stream/ObTableClientQueryAsyncStreamResult.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public void init() throws Exception {
5151
if (initialized) {
5252
return;
5353
}
54-
int maxRetries = client.getTableEntryRefreshTryTimes();
5554
// init request
5655
ObTableQueryRequest request = new ObTableQueryRequest();
5756
request.setTableName(tableName);
@@ -69,6 +68,7 @@ public void init() throws Exception {
6968
Iterator<Map.Entry<Long, ObPair<Long, ObTableParam>>> it = expectant.entrySet()
7069
.iterator();
7170
int retryTimes = 0;
71+
long startExecute = System.currentTimeMillis();
7272
while (it.hasNext()) {
7373
Map.Entry<Long, ObPair<Long, ObTableParam>> firstEntry = it.next();
7474
try {
@@ -82,10 +82,11 @@ public void init() throws Exception {
8282
tableName)));
8383
it = expectant.entrySet().iterator();
8484
retryTimes++;
85-
if (retryTimes > maxRetries) {
85+
long costMillis = System.currentTimeMillis() - startExecute;
86+
if (costMillis > client.getRuntimeMaxWait()) {
8687
RUNTIME.error("Fail to get refresh table entry response after {}",
8788
retryTimes);
88-
throw new ObTableRetryExhaustedException(
89+
throw new ObTableTimeoutExcetion(
8990
"Fail to get refresh table entry response after " + retryTimes
9091
+ "errorCode:"
9192
+ ((ObTableNeedFetchMetaException) e).getErrorCode());
@@ -264,6 +265,7 @@ public boolean next() throws Exception {
264265
Iterator<Map.Entry<Long, ObPair<Long, ObTableParam>>> it = expectant.entrySet()
265266
.iterator();
266267
int retryTimes = 0;
268+
long startExecute = System.currentTimeMillis();
267269
while (it.hasNext()) {
268270
Map.Entry<Long, ObPair<Long, ObTableParam>> entry = it.next();
269271
try {
@@ -284,10 +286,11 @@ public boolean next() throws Exception {
284286
}
285287
it = expectant.entrySet().iterator();
286288
retryTimes++;
287-
if (retryTimes > client.getTableEntryRefreshTryTimes()) {
289+
long costMillis = System.currentTimeMillis() - startExecute;
290+
if (costMillis > client.getRuntimeMaxWait()) {
288291
RUNTIME.error("Fail to get refresh table entry response after {}",
289292
retryTimes);
290-
throw new ObTableRetryExhaustedException(
293+
throw new ObTableTimeoutExcetion(
291294
"Fail to get refresh table entry response after " + retryTimes);
292295
}
293296
continue;

0 commit comments

Comments
 (0)