You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2018/07/18 07:15:12 UTC
[bookkeeper] branch master updated: [TABLE SERVICE] Fix Journal
replay issue on range deletion
This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new f4ef21f [TABLE SERVICE] Fix Journal replay issue on range deletion
f4ef21f is described below
commit f4ef21fb05f9f5826413bedb04cf00da85d56416
Author: Sijie Guo <si...@apache.org>
AuthorDate: Wed Jul 18 00:15:05 2018 -0700
[TABLE SERVICE] Fix Journal replay issue on range deletion
Descriptions of the changes in this PR:
*Motivation*
We use `\000` as an indicator for null key in the protobuf delete operation.
However when we convert the protobuf delete request to an delete operation,
we didn't take `\000` into account.
*Changes*
- Fix ProtoDeleteOpImpl and ProtoRangeOpImpl to handle '\000'
(have a separated PR for an integration test to ensure this work)
Author: Sijie Guo <si...@apache.org>
Reviewers: Enrico Olivelli <eo...@gmail.com>
This closes #1554 from sijie/fix_journal_replay
---
.../apache/bookkeeper/statelib/impl/mvcc/MVCCStoreImpl.java | 4 +++-
.../statelib/impl/mvcc/op/proto/ProtoDeleteOpImpl.java | 4 +++-
.../statelib/impl/mvcc/op/proto/ProtoRangeOpImpl.java | 10 ++++++----
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/MVCCStoreImpl.java b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/MVCCStoreImpl.java
index e7f1150..fa595dc 100644
--- a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/MVCCStoreImpl.java
+++ b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/MVCCStoreImpl.java
@@ -26,6 +26,7 @@ import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.PeekingIterator;
import com.google.common.primitives.UnsignedBytes;
+import com.google.protobuf.TextFormat;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.Unpooled;
@@ -763,7 +764,8 @@ class MVCCStoreImpl<K, V> extends RocksdbKVStore<K, V> implements MVCCStore<K, V
record = getKeyRecord(key, rawKey);
if (null == record) {
if (CompareTarget.VALUE != op.target()) {
- throw new MVCCStoreException(Code.KEY_NOT_FOUND, "Key " + key + " is not found");
+ throw new MVCCStoreException(Code.KEY_NOT_FOUND,
+ "Key '" + TextFormat.escapeBytes(rawKey) + "' is not found");
}
}
return processCompareOp(record, op);
diff --git a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoDeleteOpImpl.java b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoDeleteOpImpl.java
index 1f5f076..130d06c 100644
--- a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoDeleteOpImpl.java
+++ b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoDeleteOpImpl.java
@@ -80,7 +80,9 @@ public class ProtoDeleteOpImpl implements DeleteOp<byte[], byte[]>, DeleteOption
if (null != endKey) {
return endKey;
}
- if (null == req.getRangeEnd()) {
+ if (null == req.getRangeEnd()
+ || 0 == req.getRangeEnd().size()
+ || (1 == req.getRangeEnd().size() && req.getRangeEnd().byteAt(0) == 0)) {
endKey = null;
} else {
endKey = req.getRangeEnd().toByteArray();
diff --git a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoRangeOpImpl.java b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoRangeOpImpl.java
index f732752..74a849b 100644
--- a/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoRangeOpImpl.java
+++ b/stream/statelib/src/main/java/org/apache/bookkeeper/statelib/impl/mvcc/op/proto/ProtoRangeOpImpl.java
@@ -91,12 +91,14 @@ public class ProtoRangeOpImpl implements RangeOp<byte[], byte[]>, RangeOption<by
if (null != endKey) {
return endKey;
}
- if (null == req.getRangeEnd()) {
- key = null;
+ if (null == req.getRangeEnd()
+ || 0 == req.getRangeEnd().size()
+ || (1 == req.getRangeEnd().size() && req.getRangeEnd().byteAt(0) == 0)) {
+ endKey = null;
} else {
- key = req.getRangeEnd().toByteArray();
+ endKey = req.getRangeEnd().toByteArray();
}
- return key;
+ return endKey;
}
@Override