Skip to content

Commit 83312c3

Browse files
committed
fix log && fix getPartitionReplica return wrong part id
1 parent baaa435 commit 83312c3

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,9 @@ private <T> T execute(String tableName, OperationExecuteCallback<T> callback,
885885
}
886886
} else {
887887
String logMessage = String.format(
888-
"exhaust retry while meet NeedRefresh Exception, table name: %s, batch ops refresh table, errorCode: %d",
888+
"exhaust retry while meet NeedRefresh Exception, table name: %s, retry times: %d, errorCode: %d",
889889
tableName,
890+
runtimeRetryTimes,
890891
((ObTableException) ex).getErrorCode()
891892
);
892893
logger.warn(logMessage, ex);
@@ -2041,12 +2042,10 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
20412042
ObTableParam param = createTableParam(obTable, tableEntry, obPartitionLocationInfo, partId, tabletId);
20422043
if (ObGlobal.obVsnMajor() >= 4) {
20432044
} else {
2044-
param.setPartId(partId);
2045-
param.setTableId(tableEntry.getTableId());
20462045
param.setPartitionId(partId);
20472046
}
20482047
addr.recordAccess();
2049-
return new ObPair<>(tabletId, param);
2048+
return new ObPair<>(partId, param);
20502049
}
20512050

20522051
private ObPartitionLocationInfo getOrRefreshPartitionInfo(TableEntry tableEntry,
@@ -2116,7 +2115,7 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
21162115
if (ObGlobal.obVsnMajor() >= 4) {
21172116
long tabletId = getTabletIdByPartId(tableEntry, 0L);
21182117
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
2119-
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
2118+
replicas.add(new ObPair<>(0L, getPartitionLocation(locationInfo, route)));
21202119
} else {
21212120
replicas.add(new ObPair<Long, ReplicaLocation>(0L, getPartitionLocation(tableEntry, 0L,
21222121
route)));
@@ -2131,7 +2130,7 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
21312130
for (Long partId : partIds) {
21322131
long tabletId = getTabletIdByPartId(tableEntry, partId);
21332132
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
2134-
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
2133+
replicas.add(new ObPair<>(partId, getPartitionLocation(locationInfo, route)));
21352134
}
21362135
} else {
21372136
for (Long partId : partIds) {

src/main/java/com/alipay/oceanbase/rpc/bolt/transport/ObTableRemoting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public ObPayload invokeSync(final ObTableConnection conn, final ObPayload reques
165165
} else {
166166
String errMessage = TraceUtil.formatTraceMessage(conn, response,
167167
"receive unexpected command code: " + response.getCmdCode().value());
168-
throw new ObTableUnexpectedException(errMessage);
168+
throw new ObTableUnexpectedException(errMessage, resultCode.getRcode());
169169
}
170170

171171
payload.decode(buf);

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,26 +259,22 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
259259
}
260260
if (((ObTableException) e).isNeedRefreshTableEntry()) {
261261
needRefreshTableEntry = true;
262-
logger
263-
.warn(
264-
"tablename:{} partition id:{} stream query refresh table while meet Exception needing refresh, errorCode: {}",
265-
indexTableName, partIdWithIndex.getLeft(),
266-
((ObTableException) e).getErrorCode(), e);
267262
if (client.isRetryOnChangeMasterTimes()
268263
&& (tryTimes - 1) < client.getRuntimeRetryTimes()) {
269-
logger
270-
.warn(
271-
"tablename:{} partition id:{} stream query retry while meet Exception needing refresh, errorCode: {} , retry times {}",
272-
indexTableName, partIdWithIndex.getLeft(),
273-
((ObTableException) e).getErrorCode(), tryTimes, e);
274264
// tablet not exists, refresh table entry
275265
if (e instanceof ObTableNeedFetchAllException) {
276266
client.getOrRefreshTableEntry(indexTableName, true, true, true);
277267
throw e;
278268
}
279269
} else {
270+
String logMessage = String.format(
271+
"exhaust retry while meet NeedRefresh Exception, table name: %s, ls id: %d, batch ops refresh table, errorCode: %d",
272+
indexTableName,
273+
((ObTableException) e).getErrorCode()
274+
);
275+
logger.warn(logMessage, e);
280276
client.calculateContinuousFailure(indexTableName, e.getMessage());
281-
throw e;
277+
throw new ObTableRetryExhaustedException(logMessage, e);
282278
}
283279
} else {
284280
client.calculateContinuousFailure(indexTableName, e.getMessage());

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,24 +432,24 @@ public void partitionExecute(ObTableOperationResult[] results,
432432
} else if (ex instanceof ObTableException
433433
&& ((ObTableException) ex).isNeedRefreshTableEntry()) {
434434
needRefreshTableEntry = true;
435-
logger
436-
.warn(
437-
"tablename:{} partition id:{} batch ops refresh table while meet ObTableMasterChangeException, errorCode: {}",
438-
tableName, partId, ((ObTableException) ex).getErrorCode(), ex);
439435
if (obTableClient.isRetryOnChangeMasterTimes()
440436
&& (tryTimes - 1) < obTableClient.getRuntimeRetryTimes()) {
441437
if (ex instanceof ObTableNeedFetchAllException) {
442-
logger.warn("tablename:{}, partition_id: {} batch ops retry while meet ObTableNeedFetchAllException, errorCode: {} , retry times {}",
443-
tableName, subRequest.getPartitionId(),((ObTableException) ex).getErrorCode(),
444-
tryTimes, ex);
445438
// refresh table info
446439
obTableClient.getOrRefreshTableEntry(tableName, needRefreshTableEntry,
447440
obTableClient.isTableEntryRefreshIntervalWait(), true);
448441
throw ex;
449442
}
450443
} else {
444+
String logMessage = String.format(
445+
"exhaust retry while meet NeedRefresh Exception, table name: %s, batch ops refresh table, retry times: %d, errorCode: %d",
446+
tableName,
447+
obTableClient.getRuntimeRetryTimes(),
448+
((ObTableException) ex).getErrorCode()
449+
);
450+
logger.warn(logMessage, ex);
451451
obTableClient.calculateContinuousFailure(tableName, ex.getMessage());
452-
throw ex;
452+
throw new ObTableRetryExhaustedException(logMessage, ex);
453453
}
454454
} else {
455455
obTableClient.calculateContinuousFailure(tableName, ex.getMessage());

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ public void partitionExecute(ObTableSingleOpResult[] results,
519519
false, false);
520520
if (ObGlobal.obVsnMajor() >= 4) {
521521
obTableClient.refreshTableLocationByTabletId(entry, realTableName, obTableClient.getTabletIdByPartId(entry, originPartId));
522+
} else { // 3.x
523+
obTableClient.getOrRefreshTableEntry(realTableName, needRefreshTableEntry,
524+
obTableClient.isTableEntryRefreshIntervalWait(), false);
522525
}
523526
subObTable = obTableClient.getTableWithPartId(realTableName, originPartId, needRefreshTableEntry,
524527
obTableClient.isTableEntryRefreshIntervalWait(), false, route).
@@ -571,9 +574,10 @@ public void partitionExecute(ObTableSingleOpResult[] results,
571574
}
572575
} else {
573576
String logMessage = String.format(
574-
"exhaust retry while meet NeedRefresh Exception, table name: %s, ls id: %d, batch ops refresh table, errorCode: %d",
577+
"exhaust retry while meet NeedRefresh Exception, table name: %s, ls id: %d, batch ops refresh table, retry times: %d, errorCode: %d",
575578
realTableName,
576579
lsId,
580+
obTableClient.getRuntimeRetryTimes(),
577581
((ObTableException) ex).getErrorCode()
578582
);
579583
logger.warn(logMessage, ex);

0 commit comments

Comments
 (0)