From 68deeed1116c6eb9ed38d10a21e3cc7b87b57d95 Mon Sep 17 00:00:00 2001 From: githubgxll <1094462054@qq.com> Date: Tue, 24 Dec 2024 18:08:34 +0800 Subject: [PATCH] [fix][dingo-executor] Fix pessimistic transaction update non-existent records and insert null key issues --- .../io/dingodb/exec/operator/TxnPartUpdateOperator.java | 8 +++++--- .../dingodb/partition/base/HashRangePartitionService.java | 3 +++ .../io/dingodb/partition/base/RangePartitionService.java | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dingo-exec/src/main/java/io/dingodb/exec/operator/TxnPartUpdateOperator.java b/dingo-exec/src/main/java/io/dingodb/exec/operator/TxnPartUpdateOperator.java index 27d1d694d6..855dbdc30f 100644 --- a/dingo-exec/src/main/java/io/dingodb/exec/operator/TxnPartUpdateOperator.java +++ b/dingo-exec/src/main/java/io/dingodb/exec/operator/TxnPartUpdateOperator.java @@ -91,9 +91,11 @@ protected boolean pushTuple(Context context, Object[] tuple, Vertex vertex) { } } if (param.isHasAutoInc() && param.getAutoIncColIdx() < tuple.length) { - long autoIncVal = Long.parseLong(newTuple[param.getAutoIncColIdx()].toString()); - MetaService metaService = MetaService.root(); - metaService.updateAutoIncrement(param.getTableId(), autoIncVal); + if (newTuple[param.getAutoIncColIdx()] != null) { + long autoIncVal = Long.parseLong(newTuple[param.getAutoIncColIdx()].toString()); + MetaService metaService = MetaService.root(); + metaService.updateAutoIncrement(param.getTableId(), autoIncVal); + } } CommonId txnId = vertex.getTask().getTxnId(); CommonId tableId = param.getTableId(); diff --git a/dingo-partition-base/src/main/java/io/dingodb/partition/base/HashRangePartitionService.java b/dingo-partition-base/src/main/java/io/dingodb/partition/base/HashRangePartitionService.java index 47ebabbc63..ce8a55aa90 100644 --- a/dingo-partition-base/src/main/java/io/dingodb/partition/base/HashRangePartitionService.java +++ b/dingo-partition-base/src/main/java/io/dingodb/partition/base/HashRangePartitionService.java @@ -43,6 +43,9 @@ public int getPartNum(NavigableMap range @Override public CommonId calcPartId(byte[] key, NavigableMap ranges) { + if (key == null) { + throw new RuntimeException("key does not allow NULLs"); + } ConsistentHashing hashRing = new ConsistentHashing<>(3); NavigableMap partRanges = new TreeMap<>(); for (Map.Entry entry : ranges.entrySet()) { diff --git a/dingo-partition-base/src/main/java/io/dingodb/partition/base/RangePartitionService.java b/dingo-partition-base/src/main/java/io/dingodb/partition/base/RangePartitionService.java index 456a09be54..c37d8c8dcc 100644 --- a/dingo-partition-base/src/main/java/io/dingodb/partition/base/RangePartitionService.java +++ b/dingo-partition-base/src/main/java/io/dingodb/partition/base/RangePartitionService.java @@ -35,6 +35,9 @@ public int getPartNum(NavigableMap range @Override public CommonId calcPartId(byte [] key, NavigableMap ranges) { + if (key == null) { + throw new RuntimeException("key does not allow NULLs"); + } return ranges.floorEntry(new ComparableByteArray(key, 1)).getValue().id(); }