Skip to content

Commit e96502c

Browse files
committed
Restrict refreshTableLocationByTabletId to execute only on partitioned tables in version 4.x and above
1 parent 4d9a296 commit e96502c

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,11 @@ private <T> T executeMutation(String tableName, MutationExecuteCallback<T> callb
789789
if (null != callback.getRowKey()) {
790790
// in the case of retry, the location always needs to be refreshed here
791791
if (tryTimes > 1) {
792-
TableEntry entry = getOrRefreshTableEntry(tableName, false, false, false);
793-
Long partId = getPartition(entry, callback.getRowKey());
794-
refreshTableLocationByTabletId(entry, tableName, getTabletIdByPartId(entry, partId));
792+
TableEntry entry = getOrRefreshTableEntry(tableName, false, false, false);
793+
if (ObGlobal.obVsnMajor() >= 4 && entry.isPartitionTable()) {
794+
Long partId = getPartition(entry, callback.getRowKey());
795+
refreshTableLocationByTabletId(entry, tableName, getTabletIdByPartId(entry, partId));
796+
}
795797
}
796798
// using row key
797799
obPair = getTable(tableName, callback.getRowKey(), needRefreshTableEntry, tableEntryRefreshIntervalWait, false, route);
@@ -1340,7 +1342,7 @@ public TableEntry refreshTableLocationByTabletId(TableEntry tableEntry, String t
13401342
}
13411343
long lastRefreshTime = tableEntry.getPartitionEntry().getPartitionInfo(tabletId).getLastUpdateTime();
13421344
long currentTime = System.currentTimeMillis();
1343-
if (currentTime - lastRefreshTime < 1000) {
1345+
if (currentTime - lastRefreshTime < tableEntryRefreshIntervalCeiling) {
13441346
return tableEntry;
13451347
}
13461348
tableEntry = loadTableEntryLocationWithPriority(serverRoster, tableEntryKey, tableEntry, tabletId,
@@ -1662,7 +1664,9 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
16621664

16631665
long partId = getPartition(tableEntry, row); // partition id in 3.x, origin partId in 4.x, logicId
16641666
if (refresh) {
1665-
refreshTableLocationByTabletId(tableEntry, tableName, getTabletIdByPartId(tableEntry, partId));
1667+
if (ObGlobal.obVsnMajor() >= 4 && tableEntry.isPartitionTable()) {
1668+
refreshTableLocationByTabletId(tableEntry, tableName, getTabletIdByPartId(tableEntry, partId));
1669+
}
16661670
}
16671671
return getTableInternal(tableName, tableEntry, partId, waitForRefresh, route);
16681672
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,10 @@ public void executeWithRetry(ObTableClient client,
568568
if (retryTimes > 1) {
569569
TableEntry tableEntry = client.getOrRefreshTableEntry(tableName, false, false,
570570
false);
571-
client.refreshTableLocationByTabletId(tableEntry, tableName, entry.getValue()
572-
.getRight().getPartitionId());
571+
if (ObGlobal.obVsnMajor() >= 4 && tableEntry.isPartitionTable()) {
572+
client.refreshTableLocationByTabletId(tableEntry, tableName, entry.getValue()
573+
.getRight().getPartitionId());
574+
}
573575
}
574576
operation.accept(entry.getValue());
575577

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

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

1818
package com.alipay.oceanbase.rpc.table;
1919

20+
import com.alipay.oceanbase.rpc.ObGlobal;
2021
import com.alipay.oceanbase.rpc.ObTableClient;
2122
import com.alipay.oceanbase.rpc.exception.*;
2223
import com.alipay.oceanbase.rpc.location.model.ObServerRoute;
@@ -355,7 +356,9 @@ public void partitionExecute(ObTableOperationResult[] results,
355356
}
356357
TableEntry entry = obTableClient.getOrRefreshTableEntry(tableName, false,
357358
false, false);
358-
obTableClient.refreshTableLocationByTabletId(entry, tableName, partId);
359+
if (ObGlobal.obVsnMajor() >= 4 && entry.isPartitionTable()) {
360+
obTableClient.refreshTableLocationByTabletId(entry, tableName, partId);
361+
}
359362
ObTableParam newParam = obTableClient.getTableWithPartId(tableName, partId,
360363
false, obTableClient.isTableEntryRefreshIntervalWait(), needFetchAllRouteInfo, route)
361364
.getRight();

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

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

1818
package com.alipay.oceanbase.rpc.table;
1919

20+
import com.alipay.oceanbase.rpc.ObGlobal;
2021
import com.alipay.oceanbase.rpc.ObTableClient;
2122
import com.alipay.oceanbase.rpc.checkandmutate.CheckAndInsUp;
2223
import com.alipay.oceanbase.rpc.exception.*;
@@ -476,7 +477,9 @@ public void partitionExecute(ObTableSingleOpResult[] results,
476477
}
477478
TableEntry entry = obTableClient.getOrRefreshTableEntry(tableName, false,
478479
false, false);
479-
obTableClient.refreshTableLocationByTabletId(entry, tableName, obTableClient.getTabletIdByPartId(entry, originPartId));
480+
if (ObGlobal.obVsnMajor() >= 4 && entry.isPartitionTable()) {
481+
obTableClient.refreshTableLocationByTabletId(entry, tableName, obTableClient.getTabletIdByPartId(entry, originPartId));
482+
}
480483
subObTable = obTableClient.getTableWithPartId(tableName, originPartId, needRefreshTableEntry,
481484
obTableClient.isTableEntryRefreshIntervalWait(), false, route).
482485
getRight().getObTable();

0 commit comments

Comments
 (0)