From cddceeaab666c1bc301eb4267e7a2530fb013f47 Mon Sep 17 00:00:00 2001 From: stuBirdFly <1065492934@qq.com> Date: Wed, 6 Nov 2024 11:38:35 +0800 Subject: [PATCH] Fix the issue where the tablet_id is incorrect when the partition table has a single partition --- src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java | 6 ++---- .../com/alipay/oceanbase/rpc/location/LocationUtil.java | 4 ++-- .../com/alipay/oceanbase/rpc/location/model/TableEntry.java | 4 +++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java b/src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java index f289bcb0..83ecb1e8 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java +++ b/src/main/java/com/alipay/oceanbase/rpc/ObTableClient.java @@ -1640,8 +1640,7 @@ private ObPair getTable(String tableName, Object[] rowKey, TableEntry tableEntry = getOrRefreshTableEntry(tableName, refresh, waitForRefresh, needFetchAll); Row row = new Row(); - if (tableEntry.isPartitionTable() - && tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) { + if (tableEntry.isPartitionTable()) { List curTableRowKeyNames = new ArrayList(); Map tableRowKeyEle = getRowKeyElement(tableName); if (tableRowKeyEle != null) { @@ -2052,8 +2051,7 @@ public List> getTables(String tableName, ObTableQuery Row startRow = new Row(); Row endRow = new Row(); // ensure the format of column names and values if the current table is a table with partition - if (tableEntry.isPartitionTable() - && tableEntry.getPartitionInfo().getLevel() != ObPartitionLevel.LEVEL_ZERO) { + if (tableEntry.isPartitionTable()) { // scanRangeColumn may be longer than start/end in prefix scanning situation if (scanRangeColumns == null || scanRangeColumns.size() < start.length) { throw new IllegalArgumentException( diff --git a/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java b/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java index a78ea8c9..ecddcf9a 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java +++ b/src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java @@ -725,10 +725,10 @@ private static TableEntry getTableEntryFromRemote(Connection connection, TableEn if (null != tableEntry) { tableEntry.setTableEntryKey(key); // TODO: check capacity flag later + // fetch partition info + fetchPartitionInfo(connection, tableEntry); // fetch tablet ids when table is partition table if (tableEntry.isPartitionTable()) { - // fetch partition info - fetchPartitionInfo(connection, tableEntry); if (null != tableEntry.getPartitionInfo()) { // fetch first range part if (null != tableEntry.getPartitionInfo().getFirstPartDesc()) { diff --git a/src/main/java/com/alipay/oceanbase/rpc/location/model/TableEntry.java b/src/main/java/com/alipay/oceanbase/rpc/location/model/TableEntry.java index 260a067c..65df1702 100644 --- a/src/main/java/com/alipay/oceanbase/rpc/location/model/TableEntry.java +++ b/src/main/java/com/alipay/oceanbase/rpc/location/model/TableEntry.java @@ -105,7 +105,9 @@ public Long getReplicaNum() { * Is partition table. */ public boolean isPartitionTable() { - return this.partitionNum > 1; + return partitionNum > 1 || (partitionInfo != null && partitionInfo.getLevel() + .getIndex() > ObPartitionLevel.LEVEL_ZERO.getIndex() && partitionInfo.getLevel() + .getIndex() < ObPartitionLevel.UNKNOWN.getIndex()); } /*