Skip to content

Commit 739cdd4

Browse files
committed
fix same tablegroup caching table dropped and request with same tabletId bug
1 parent e6a2428 commit 739cdd4

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public abstract class AbstractQueryStreamResult extends AbstractPayload implemen
7171
private ObReadConsistency readConsistency = ObReadConsistency.STRONG;
7272
// ObRowKey objs: [startKey, MIN_OBJECT, MIN_OBJECT]
7373
public List<ObObj> currentStartKey;
74-
protected ObTableClient client;
75-
74+
protected ObTableClient client;
75+
7676
/*
7777
* Get pcode.
7878
*/
@@ -146,8 +146,10 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
146146
route.setBlackList(failedServerList);
147147
}
148148
if (ObGlobal.obVsnMajor() >= 4) {
149-
TableEntry tableEntry = client.getOrRefreshTableEntry(indexTableName, false, false, false);
150-
client.refreshTableLocationByTabletId(tableEntry, indexTableName, client.getTabletIdByPartId(tableEntry, partIdWithIndex.getLeft()));
149+
TableEntry tableEntry = client.getOrRefreshTableEntry(indexTableName,
150+
false, false, false);
151+
client.refreshTableLocationByTabletId(tableEntry, indexTableName,
152+
client.getTabletIdByPartId(tableEntry, partIdWithIndex.getLeft()));
151153
}
152154

153155
subObTable = client
@@ -239,12 +241,15 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
239241
}
240242
} else if (e instanceof ObTableException) {
241243
if ((((ObTableException) e).getErrorCode() == ResultCodes.OB_TABLE_NOT_EXIST.errorCode || ((ObTableException) e)
242-
.getErrorCode() == ResultCodes.OB_NOT_SUPPORTED.errorCode)
244+
.getErrorCode() == ResultCodes.OB_NOT_SUPPORTED.errorCode || ((ObTableException) e)
245+
.getErrorCode() == ResultCodes.OB_SCHEMA_ERROR.errorCode)
243246
&& ((request instanceof ObTableQueryAsyncRequest && ((ObTableQueryAsyncRequest) request).getObTableQueryRequest().getTableQuery().isHbaseQuery())
244247
|| (request instanceof ObTableQueryRequest && ((ObTableQueryRequest) request).getTableQuery().isHbaseQuery()))
245248
&& client.getTableGroupInverted().get(indexTableName) != null) {
246249
// table not exists && hbase mode && table group exists , three condition both
247250
client.eraseTableGroupFromCache(tableName);
251+
indexTableName = client.tryGetTableNameFromTableGroupCache(tableName,
252+
true);
248253
}
249254
if (((ObTableException) e).isNeedRefreshTableEntry()) {
250255
needRefreshTableEntry = true;
@@ -256,11 +261,10 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
256261
throw e;
257262
}
258263
} else {
259-
String logMessage = String.format(
264+
String logMessage = String
265+
.format(
260266
"exhaust retry while meet NeedRefresh Exception, table name: %s, batch ops refresh table, errorCode: %d",
261-
indexTableName,
262-
((ObTableException) e).getErrorCode()
263-
);
267+
indexTableName, ((ObTableException) e).getErrorCode());
264268
logger.warn(logMessage, e);
265269
client.calculateContinuousFailure(indexTableName, e.getMessage());
266270
throw new ObTableRetryExhaustedException(logMessage, e);
@@ -434,7 +438,8 @@ protected void checkStatus() throws IllegalStateException {
434438
}
435439

436440
if (closed) {
437-
throw new IllegalStateException("table " + indexTableName + " query stream result is closed");
441+
throw new IllegalStateException("table " + indexTableName
442+
+ " query stream result is closed");
438443
}
439444
}
440445

@@ -565,7 +570,7 @@ public void init() throws Exception {
565570
if (tableQuery.getBatchSize() == -1) {
566571
if (!expectant.isEmpty()) {
567572
Iterator<Map.Entry<Long, ObPair<Long, ObTableParam>>> it = expectant.entrySet()
568-
.iterator();
573+
.iterator();
569574
int retryTimes = 0;
570575
while (it.hasNext()) {
571576
Map.Entry<Long, ObPair<Long, ObTableParam>> entry = it.next();
@@ -579,10 +584,11 @@ public void init() throws Exception {
579584
retryTimes++;
580585
if (retryTimes > client.getRuntimeRetryTimes()) {
581586
RUNTIME.error("Fail to get refresh table entry response after {}",
582-
retryTimes);
587+
retryTimes);
583588
throw new ObTableRetryExhaustedException(
584-
"Fail to get refresh table entry response after " + retryTimes +
585-
"errorCode:" + ((ObTableNeedFetchAllException) e).getErrorCode());
589+
"Fail to get refresh table entry response after " + retryTimes
590+
+ "errorCode:"
591+
+ ((ObTableNeedFetchAllException) e).getErrorCode());
586592

587593
}
588594
} else {

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ public void partitionExecute(ObTableSingleOpResult[] results,
582582
} else if (ex instanceof ObTableException
583583
&& ((ObTableException) ex).isNeedRefreshTableEntry()) {
584584
needRefreshTableEntry = true;
585-
if (((ObTableException) ex).getErrorCode() == ResultCodes.OB_TABLE_NOT_EXIST.errorCode
585+
if ((((ObTableException) ex).getErrorCode() == ResultCodes.OB_TABLE_NOT_EXIST.errorCode ||
586+
((ObTableException) ex).getErrorCode() == ResultCodes.OB_SCHEMA_ERROR.errorCode)
586587
&& obTableClient.isTableGroupName(tableName)
587588
&& obTableClient.getTableGroupInverted().get(realTableName) != null) {
588589
// TABLE_NOT_EXIST + tableName is tableGroup + TableGroup cache is not empty

0 commit comments

Comments
 (0)