Skip to content

Commit 346f39d

Browse files
guojn1ketor
authored andcommitted
[fix][dingo-calcite] NullPointer caused by concurrent transactions
1 parent cca96b4 commit 346f39d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

dingo-calcite/src/main/java/io/dingodb/calcite/utils/MetaServiceUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.dingodb.calcite.utils;
1818

19+
import io.dingodb.calcite.DingoTable;
1920
import io.dingodb.common.CommonId;
2021
import io.dingodb.meta.MetaService;
2122
import org.apache.calcite.plan.RelOptTable;
@@ -31,15 +32,19 @@ private MetaServiceUtils() {
3132
}
3233

3334
public static @NonNull CommonId getTableId(RelOptTable table) {
34-
String tableName = getTableName(table);
35-
MetaService metaService = getMetaService(table);
36-
return metaService.getTable(tableName).getTableId();
35+
//String tableName = getTableName(table);
36+
//MetaService metaService = getMetaService(table);
37+
//return metaService.getTable(tableName).getTableId();
38+
DingoTable dingoTable = table.unwrapOrThrow(DingoTable.class);
39+
return dingoTable.getTable().tableId;
3740
}
3841

3942
public static @NonNull TableInfo getTableInfo(RelOptTable table) {
40-
String tableName = getTableName(table);
43+
//String tableName = getTableName(table);
4144
MetaService metaService = getMetaService(table);
42-
CommonId tableId = metaService.getTable(tableName).getTableId();
45+
DingoTable dingoTable = table.unwrapOrThrow(DingoTable.class);
46+
CommonId tableId = dingoTable.getTable().tableId;
47+
//CommonId tableId = metaService.getTable(tableName).getTableId();
4348
return new TableInfo(
4449
tableId,
4550
metaService.getRangeDistribution(tableId)

dingo-exec/src/main/java/io/dingodb/exec/transaction/util/TransactionUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ public static Map<CommonId, List<byte[]>> multiKeySplitRegionId(CommonId tableId
125125

126126
public static IndexTable getIndexDefinitions(CommonId tableId) {
127127
MetaService root = MetaService.root();
128-
return (IndexTable) root.getTable(tableId);
128+
Table table = root.getTable(tableId);
129+
if (!(table instanceof IndexTable)) {
130+
LogUtils.error(log, "except indexTable, bug not, tableId:{}, act table", tableId, table);
131+
}
132+
return (IndexTable) table;
129133
}
130134
public static List<byte[]> mutationToKey(List<Mutation> mutations) {
131135
List<byte[]> keys = new ArrayList<>(mutations.size());

0 commit comments

Comments
 (0)