Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,9 @@ private <T> T executeMutation(String tableName, MutationExecuteCallback<T> callb
if (tryTimes > 1) {
TableEntry entry = getOrRefreshTableEntry(tableName, false, false, false);
Long partId = getPartition(entry, callback.getRowKey());
refreshTableLocationByTabletId(entry, tableName, getTabletIdByPartId(entry, partId));
if (ObGlobal.obVsnMajor() >= 4) {
refreshTableLocationByTabletId(entry, tableName, getTabletIdByPartId(entry, partId));
}
}
// using row key
obPair = getTable(tableName, callback.getRowKey(), needRefreshTableEntry, tableEntryRefreshIntervalWait, false, route);
Expand Down Expand Up @@ -1661,7 +1663,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
}

long partId = getPartition(tableEntry, row); // partition id in 3.x, origin partId in 4.x, logicId
if (refresh) {
if (refresh && ObGlobal.obVsnMajor() >= 4) {
refreshTableLocationByTabletId(tableEntry, tableName, getTabletIdByPartId(tableEntry, partId));
}
return getTableInternal(tableName, tableEntry, partId, waitForRefresh, route);
Expand Down Expand Up @@ -1895,9 +1897,7 @@ private ObPartitionLocationInfo getOrRefreshPartitionInfo(TableEntry tableEntry,
ObPartitionLocationInfo obPartitionLocationInfo = tableEntry.getPartitionEntry()
.getPartitionInfo(tabletId);
if (!obPartitionLocationInfo.initialized.get()) {
if (ObGlobal.obVsnMajor() >= 4) {
tableEntry = refreshTableLocationByTabletId(tableEntry, tableName, tabletId);
}
tableEntry = refreshTableLocationByTabletId(tableEntry, tableName, tabletId);
obPartitionLocationInfo = tableEntry.getPartitionEntry().getPartitionInfo(tabletId);
obPartitionLocationInfo.initializationLatch.await();
}
Expand Down Expand Up @@ -1938,9 +1938,14 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
List<ObPair<Long, ReplicaLocation>> replicas = new ArrayList<>();

if (!tableEntry.isPartitionTable() || tableEntry.getPartitionInfo().getLevel() == ObPartitionLevel.LEVEL_ZERO) {
long tabletId = getTabletIdByPartId(tableEntry, 0L);
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
if (ObGlobal.obVsnMajor() >= 4) {
long tabletId = getTabletIdByPartId(tableEntry, 0L);
ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo(tableEntry, tableName, tabletId);
replicas.add(new ObPair<>(tabletId, getPartitionLocation(locationInfo, route)));
} else {
replicas.add(new ObPair<Long, ReplicaLocation>(0L, getPartitionLocation(tableEntry, 0L,
route)));
}
return replicas;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.alipay.oceanbase.rpc.table;

import com.alipay.oceanbase.rpc.ObGlobal;
import com.alipay.oceanbase.rpc.ObTableClient;
import com.alipay.oceanbase.rpc.exception.*;
import com.alipay.oceanbase.rpc.location.model.ObServerRoute;
Expand Down Expand Up @@ -355,7 +356,9 @@ public void partitionExecute(ObTableOperationResult[] results,
}
TableEntry entry = obTableClient.getOrRefreshTableEntry(tableName, false,
false, false);
obTableClient.refreshTableLocationByTabletId(entry, tableName, partId);
if (ObGlobal.obVsnMajor() >= 4) {
obTableClient.refreshTableLocationByTabletId(entry, tableName, partId);
}
ObTableParam newParam = obTableClient.getTableWithPartId(tableName, partId,
false, obTableClient.isTableEntryRefreshIntervalWait(),
needFetchAllRouteInfo, route).getRight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.alipay.oceanbase.rpc.table;

import com.alipay.oceanbase.rpc.ObGlobal;
import com.alipay.oceanbase.rpc.ObTableClient;
import com.alipay.oceanbase.rpc.checkandmutate.CheckAndInsUp;
import com.alipay.oceanbase.rpc.exception.*;
Expand Down Expand Up @@ -476,7 +477,9 @@ public void partitionExecute(ObTableSingleOpResult[] results,
}
TableEntry entry = obTableClient.getOrRefreshTableEntry(tableName, false,
false, false);
obTableClient.refreshTableLocationByTabletId(entry, tableName, obTableClient.getTabletIdByPartId(entry, originPartId));
if (ObGlobal.obVsnMajor() >= 4) {
obTableClient.refreshTableLocationByTabletId(entry, tableName, obTableClient.getTabletIdByPartId(entry, originPartId));
}
subObTable = obTableClient.getTableWithPartId(tableName, originPartId, needRefreshTableEntry,
obTableClient.isTableEntryRefreshIntervalWait(), false, route).
getRight().getObTable();
Expand Down