Skip to content

Commit 7739773

Browse files
committed
Revert "adapt for distributedExecute"
This reverts commit 095ccbe.
1 parent 095ccbe commit 7739773

File tree

5 files changed

+47
-150
lines changed

5 files changed

+47
-150
lines changed

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

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,7 @@ public class LocationUtil {
189189
+ " AND A.tenant_name = ? "
190190
+ " AND A.database_name = ? "
191191
+ " AND A.table_name = ?;";
192-
private static final String PROXY_LOCATION_SQL_PARTITION_BY_TABLETID_WITHOUT_V4 = "SELECT /*+READ_CONSISTENCY(WEAK)*/ "
193-
+ " A.tablet_id as tablet_id, "
194-
+ " A.svr_ip as svr_ip, "
195-
+ " A.sql_port as sql_port, "
196-
+ " A.table_id as table_id, "
197-
+ " A.role as role, "
198-
+ " A.replica_num as replica_num, "
199-
+ " A.part_num as part_num, "
200-
+ " (SELECT B.svr_port FROM oceanbase.__all_server B WHERE A.svr_ip = B.svr_ip AND A.sql_port = B.inner_port) as svr_port, "
201-
+ " (SELECT B.status FROM oceanbase.__all_server B WHERE A.svr_ip = B.svr_ip AND A.sql_port = B.inner_port) as status, "
202-
+ " (SELECT B.stop_time FROM oceanbase.__all_server B WHERE A.svr_ip = B.svr_ip AND A.sql_port = B.inner_port) as stop_time, "
203-
+ " A.spare1 as replica_type "
204-
+ "FROM "
205-
+ " oceanbase.__all_virtual_proxy_schema A "
206-
+ "WHERE "
207-
+ " A.tablet_id = ? "
208-
+ " AND A.tenant_name = ? "
209-
+ " AND A.database_name = ? "
210-
+ " AND A.table_name = ?;";
192+
211193
private static final String PROXY_FIRST_PARTITION_SQL_V4 = "SELECT /*+READ_CONSISTENCY(WEAK)*/ part_id, part_name, tablet_id, high_bound_val, sub_part_num "
212194
+ "FROM oceanbase.__all_virtual_proxy_partition "
213195
+ "WHERE tenant_name = ? and table_id = ? LIMIT ?;";
@@ -517,8 +499,7 @@ public static TableEntry loadTableEntryLocationWithPriority(final ServerRoster s
517499
final long socketTimeout,
518500
final long priorityTimeout,
519501
final long cachingTimeout,
520-
final ObUserAuth sysUA,
521-
boolean withLsId)
502+
final ObUserAuth sysUA)
522503
throws ObTableEntryRefreshException {
523504

524505
return callTableEntryRefreshWithPriority(serverRoster, priorityTimeout, cachingTimeout,
@@ -531,7 +512,7 @@ TableEntry execute(ObServerAddr obServerAddr) throws ObTableEntryRefreshExceptio
531512
TableEntry execute(Connection connection)
532513
throws ObTablePartitionLocationRefreshException {
533514
return getTableEntryLocationFromRemote(connection, key, tableEntry,
534-
tabletId, withLsId);
515+
tabletId);
535516
}
536517
});
537518
}
@@ -812,14 +793,10 @@ private static TableEntry getTableEntryFromRemote(Connection connection, TableEn
812793
}
813794

814795
// Note: This code is applicable only for refreshing locations based on tablet ID in version 4.x
815-
private static String genLocationSQLByTabletId(boolean withLsId) {
796+
private static String genLocationSQLByTabletId() {
816797
String sql = null;
817798
if (ObGlobal.obVsnMajor() >= 4) {
818-
if (withLsId) {
819-
sql = PROXY_LOCATION_SQL_PARTITION_BY_TABLETID_V4;
820-
} else {
821-
sql = PROXY_LOCATION_SQL_PARTITION_BY_TABLETID_WITHOUT_V4;
822-
}
799+
sql = PROXY_LOCATION_SQL_PARTITION_BY_TABLETID_V4;
823800
} else {
824801
throw new FeatureNotSupportedException("not support ob version less than 4");
825802
}
@@ -886,13 +863,12 @@ private static String genLocationSQLByOffset(TableEntry tableEntry, int offset,
886863
public static TableEntry getTableEntryLocationFromRemote(Connection connection,
887864
TableEntryKey key,
888865
TableEntry tableEntry,
889-
Long tabletId,
890-
boolean withLsId)
866+
Long tabletId)
891867
throws ObTablePartitionLocationRefreshException {
892868
PreparedStatement ps = null;
893869
ResultSet rs = null;
894870
ObPartitionEntry partitionEntry = tableEntry.getPartitionEntry();
895-
String sql = genLocationSQLByTabletId(withLsId);
871+
String sql = genLocationSQLByTabletId();
896872
ObPartitionLocationInfo partitionLocationInfo = partitionEntry.getPartitionInfo(tabletId);
897873
// return quickly if recently refreshed
898874
if (System.currentTimeMillis() - partitionLocationInfo.getLastUpdateTime()
@@ -907,7 +883,7 @@ public static TableEntry getTableEntryLocationFromRemote(Connection connection,
907883
ps.setString(4, key.getDatabaseName());
908884
ps.setString(5, key.getTableName());
909885
rs = ps.executeQuery();
910-
getPartitionLocationFromResultSetByTablet(tableEntry, rs, partitionEntry, tabletId, withLsId);
886+
getPartitionLocationFromResultSetByTablet(tableEntry, rs, partitionEntry, tabletId);
911887
} catch (Exception e) {
912888
RUNTIME.error(LCD.convert("01-00010"), key, tableEntry, e);
913889
throw new ObTablePartitionLocationRefreshException(format(
@@ -1241,8 +1217,7 @@ private static TableEntry getTableEntryFromResultSet(TableEntryKey key, ResultSe
12411217
private static ObPartitionEntry getPartitionLocationFromResultSetByTablet(TableEntry tableEntry,
12421218
ResultSet rs,
12431219
ObPartitionEntry partitionEntry,
1244-
long tabletId,
1245-
boolean withLsId)
1220+
long tabletId)
12461221
throws SQLException,
12471222
ObTablePartitionLocationRefreshException {
12481223

@@ -1257,7 +1232,7 @@ private static ObPartitionEntry getPartitionLocationFromResultSetByTablet(TableE
12571232
ReplicaLocation replica = buildReplicaLocation(rs);
12581233
long partitionId = (ObGlobal.obVsnMajor() >= 4) ? rs.getLong("tablet_id") : rs
12591234
.getLong("partition_id");
1260-
long lsId = ObGlobal.obVsnMajor() >= 4 && withLsId ? rs.getLong("ls_id") : INVALID_LS_ID;
1235+
long lsId = ObGlobal.obVsnMajor() >= 4 ? rs.getLong("ls_id") : INVALID_LS_ID;
12611236
if (rs.wasNull() && ObGlobal.obVsnMajor() >= 4) {
12621237
lsId = INVALID_LS_ID; // For non-partitioned table
12631238
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import java.util.*;
3939
import java.util.concurrent.atomic.AtomicReference;
4040

41-
import static com.alipay.oceanbase.rpc.constant.Constants.INVALID_TABLET_ID;
4241
import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.RUNTIME;
4342

4443
public class ObTableClientQueryAsyncStreamResult extends AbstractQueryStreamResult {
@@ -113,10 +112,9 @@ protected ObTableQueryAsyncResult referToNewPartition(ObPair<Long, ObTableParam>
113112
throws Exception {
114113
ObTableParam obTableParam = partIdWithObTable.getRight();
115114
ObTableQueryRequest queryRequest = asyncRequest.getObTableQueryRequest();
116-
long partitionId = client.getServerCapacity().isSupportSecondaryPartition() ?
117-
INVALID_TABLET_ID : obTableParam.getPartitionId();
115+
118116
// refresh request info
119-
queryRequest.setPartitionId(partitionId);
117+
queryRequest.setPartitionId(obTableParam.getPartitionId());
120118
queryRequest.setTableId(obTableParam.getTableId());
121119
if (operationTimeout > 0) {
122120
asyncRequest.setTimeout(operationTimeout);

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,16 @@
3333
import java.util.Map;
3434
import java.util.concurrent.atomic.AtomicReference;
3535

36-
import static com.alipay.oceanbase.rpc.protocol.payload.Constants.INVALID_TABLET_ID;
37-
3836
public class ObTableClientQueryStreamResult extends AbstractQueryStreamResult {
3937
private static final Logger logger = TableClientLoggerFactory
4038
.getLogger(ObTableClientQueryStreamResult.class);
4139

4240
protected ObTableQueryResult referToNewPartition(ObPair<Long, ObTableParam> partIdWithObTable)
4341
throws Exception {
44-
long partitionId = client.getServerCapacity().isSupportDistributedExecute() ?
45-
INVALID_TABLET_ID : partIdWithObTable.getRight().getPartitionId();
4642
ObTableQueryRequest request = new ObTableQueryRequest();
4743
request.setTableName(tableName);
4844
request.setTableQuery(tableQuery);
49-
request.setPartitionId(partitionId);
45+
request.setPartitionId(partIdWithObTable.getRight().getPartitionId());
5046
request.setTableId(partIdWithObTable.getRight().getTableId());
5147
request.setEntityType(entityType);
5248
if (operationTimeout > 0) {

0 commit comments

Comments
 (0)