You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jj...@apache.org on 2017/09/05 19:01:37 UTC
[1/6] cassandra git commit: Change repair midpoint logging for tiny
ranges
Repository: cassandra
Updated Branches:
refs/heads/cassandra-3.0 0493545dd -> bc5c2316c
refs/heads/cassandra-3.11 3f5f70281 -> 90b39dc61
refs/heads/trunk fa36044a5 -> dcef7c7ed
Change repair midpoint logging for tiny ranges
Patch by Jeff Jirsa; Reviewed by Blake Eggleston for CASSANDRA-13603
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bc5c2316
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bc5c2316
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bc5c2316
Branch: refs/heads/cassandra-3.0
Commit: bc5c2316c5acfc1ee0ef101a3ebf00d03c89e283
Parents: 0493545
Author: Jeff Jirsa <jj...@apple.com>
Authored: Tue Sep 5 11:57:58 2017 -0700
Committer: Jeff Jirsa <jj...@apple.com>
Committed: Tue Sep 5 11:57:58 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/utils/MerkleTree.java | 23 +++++++++----
.../apache/cassandra/utils/MerkleTreeTest.java | 34 ++++++++++++++++++++
3 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a3eccf2..4302fdf 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.15
+ * Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
* Better handle corrupt final commitlog segment (CASSANDRA-11995)
* StreamingHistogram is not thread safe (CASSANDRA-13756)
* Fix MV timestamp issues (CASSANDRA-11500)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/src/java/org/apache/cassandra/utils/MerkleTree.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/MerkleTree.java b/src/java/org/apache/cassandra/utils/MerkleTree.java
index 0d5a469..22b61e8 100644
--- a/src/java/org/apache/cassandra/utils/MerkleTree.java
+++ b/src/java/org/apache/cassandra/utils/MerkleTree.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.*;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.PeekingIterator;
@@ -246,12 +247,20 @@ public class MerkleTree implements Serializable
if (lhash != null && rhash != null && !Arrays.equals(lhash, rhash))
{
- logger.debug("Digest mismatch detected, traversing trees [{}, {}]", ltree, rtree);
- if (FULLY_INCONSISTENT == differenceHelper(ltree, rtree, diff, active))
+ if(lnode instanceof Leaf || rnode instanceof Leaf)
{
- logger.debug("Range {} fully inconsistent", active);
+ logger.debug("Digest mismatch detected among leaf nodes {}, {}", lnode, rnode);
diff.add(active);
}
+ else
+ {
+ logger.debug("Digest mismatch detected, traversing trees [{}, {}]", ltree, rtree);
+ if (FULLY_INCONSISTENT == differenceHelper(ltree, rtree, diff, active))
+ {
+ logger.debug("Range {} fully inconsistent", active);
+ diff.add(active);
+ }
+ }
}
else if (lhash == null || rhash == null)
diff.add(active);
@@ -265,6 +274,7 @@ public class MerkleTree implements Serializable
* Takes two trees and a range for which they have hashes, but are inconsistent.
* @return FULLY_INCONSISTENT if active is inconsistent, PARTIALLY_INCONSISTENT if only a subrange is inconsistent.
*/
+ @VisibleForTesting
static int differenceHelper(MerkleTree ltree, MerkleTree rtree, List<TreeRange> diff, TreeRange active)
{
if (active.depth == Byte.MAX_VALUE)
@@ -274,10 +284,9 @@ public class MerkleTree implements Serializable
// sanity check for midpoint calculation, see CASSANDRA-13052
if (midpoint.equals(active.left) || midpoint.equals(active.right))
{
- // Unfortunately we can't throw here to abort the validation process, as the code is executed in it's own
- // thread with the caller waiting for a condition to be signaled after completion and without an option
- // to indicate an error (2.x only).
- logger.error("Invalid midpoint {} for [{},{}], range will be reported inconsistent", midpoint, active.left, active.right);
+ // If the midpoint equals either the left or the right, we have a range that's too small to split - we'll simply report the
+ // whole range as inconsistent
+ logger.debug("({}) No sane midpoint ({}) for range {} , marking whole range as inconsistent", active.depth, midpoint, active);
return FULLY_INCONSISTENT;
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
index c9aa09f..64aea24 100644
--- a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
+++ b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
@@ -472,6 +472,40 @@ public class MerkleTreeTest
List<TreeRange> diffs = MerkleTree.difference(ltree, rtree);
assertEquals(Lists.newArrayList(range), diffs);
+ assertEquals(MerkleTree.FULLY_INCONSISTENT, MerkleTree.differenceHelper(ltree, rtree, new ArrayList<>(), new MerkleTree.TreeDifference(ltree.fullRange.left, ltree.fullRange.right, (byte)0)));
+ }
+
+ /**
+ * matching should behave as expected, even with extremely small ranges
+ */
+ @Test
+ public void matchingSmallRange()
+ {
+ Token start = new BigIntegerToken("9");
+ Token end = new BigIntegerToken("10");
+ Range<Token> range = new Range<>(start, end);
+
+ MerkleTree ltree = new MerkleTree(partitioner, range, RECOMMENDED_DEPTH, 16);
+ ltree.init();
+ MerkleTree rtree = new MerkleTree(partitioner, range, RECOMMENDED_DEPTH, 16);
+ rtree.init();
+
+ byte[] h1 = "asdf".getBytes();
+ byte[] h2 = "asdf".getBytes();
+
+
+ // add dummy hashes to both trees
+ for (TreeRange tree : ltree.invalids())
+ {
+ tree.addHash(new RowHash(range.right, h1, h1.length));
+ }
+ for (TreeRange tree : rtree.invalids())
+ {
+ tree.addHash(new RowHash(range.right, h2, h2.length));
+ }
+
+ // top level difference() should show no differences
+ assertEquals(MerkleTree.difference(ltree, rtree), Lists.newArrayList());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[2/6] cassandra git commit: Change repair midpoint logging for tiny
ranges
Posted by jj...@apache.org.
Change repair midpoint logging for tiny ranges
Patch by Jeff Jirsa; Reviewed by Blake Eggleston for CASSANDRA-13603
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bc5c2316
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bc5c2316
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bc5c2316
Branch: refs/heads/cassandra-3.11
Commit: bc5c2316c5acfc1ee0ef101a3ebf00d03c89e283
Parents: 0493545
Author: Jeff Jirsa <jj...@apple.com>
Authored: Tue Sep 5 11:57:58 2017 -0700
Committer: Jeff Jirsa <jj...@apple.com>
Committed: Tue Sep 5 11:57:58 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/utils/MerkleTree.java | 23 +++++++++----
.../apache/cassandra/utils/MerkleTreeTest.java | 34 ++++++++++++++++++++
3 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a3eccf2..4302fdf 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.15
+ * Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
* Better handle corrupt final commitlog segment (CASSANDRA-11995)
* StreamingHistogram is not thread safe (CASSANDRA-13756)
* Fix MV timestamp issues (CASSANDRA-11500)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/src/java/org/apache/cassandra/utils/MerkleTree.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/MerkleTree.java b/src/java/org/apache/cassandra/utils/MerkleTree.java
index 0d5a469..22b61e8 100644
--- a/src/java/org/apache/cassandra/utils/MerkleTree.java
+++ b/src/java/org/apache/cassandra/utils/MerkleTree.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.*;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.PeekingIterator;
@@ -246,12 +247,20 @@ public class MerkleTree implements Serializable
if (lhash != null && rhash != null && !Arrays.equals(lhash, rhash))
{
- logger.debug("Digest mismatch detected, traversing trees [{}, {}]", ltree, rtree);
- if (FULLY_INCONSISTENT == differenceHelper(ltree, rtree, diff, active))
+ if(lnode instanceof Leaf || rnode instanceof Leaf)
{
- logger.debug("Range {} fully inconsistent", active);
+ logger.debug("Digest mismatch detected among leaf nodes {}, {}", lnode, rnode);
diff.add(active);
}
+ else
+ {
+ logger.debug("Digest mismatch detected, traversing trees [{}, {}]", ltree, rtree);
+ if (FULLY_INCONSISTENT == differenceHelper(ltree, rtree, diff, active))
+ {
+ logger.debug("Range {} fully inconsistent", active);
+ diff.add(active);
+ }
+ }
}
else if (lhash == null || rhash == null)
diff.add(active);
@@ -265,6 +274,7 @@ public class MerkleTree implements Serializable
* Takes two trees and a range for which they have hashes, but are inconsistent.
* @return FULLY_INCONSISTENT if active is inconsistent, PARTIALLY_INCONSISTENT if only a subrange is inconsistent.
*/
+ @VisibleForTesting
static int differenceHelper(MerkleTree ltree, MerkleTree rtree, List<TreeRange> diff, TreeRange active)
{
if (active.depth == Byte.MAX_VALUE)
@@ -274,10 +284,9 @@ public class MerkleTree implements Serializable
// sanity check for midpoint calculation, see CASSANDRA-13052
if (midpoint.equals(active.left) || midpoint.equals(active.right))
{
- // Unfortunately we can't throw here to abort the validation process, as the code is executed in it's own
- // thread with the caller waiting for a condition to be signaled after completion and without an option
- // to indicate an error (2.x only).
- logger.error("Invalid midpoint {} for [{},{}], range will be reported inconsistent", midpoint, active.left, active.right);
+ // If the midpoint equals either the left or the right, we have a range that's too small to split - we'll simply report the
+ // whole range as inconsistent
+ logger.debug("({}) No sane midpoint ({}) for range {} , marking whole range as inconsistent", active.depth, midpoint, active);
return FULLY_INCONSISTENT;
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
index c9aa09f..64aea24 100644
--- a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
+++ b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
@@ -472,6 +472,40 @@ public class MerkleTreeTest
List<TreeRange> diffs = MerkleTree.difference(ltree, rtree);
assertEquals(Lists.newArrayList(range), diffs);
+ assertEquals(MerkleTree.FULLY_INCONSISTENT, MerkleTree.differenceHelper(ltree, rtree, new ArrayList<>(), new MerkleTree.TreeDifference(ltree.fullRange.left, ltree.fullRange.right, (byte)0)));
+ }
+
+ /**
+ * matching should behave as expected, even with extremely small ranges
+ */
+ @Test
+ public void matchingSmallRange()
+ {
+ Token start = new BigIntegerToken("9");
+ Token end = new BigIntegerToken("10");
+ Range<Token> range = new Range<>(start, end);
+
+ MerkleTree ltree = new MerkleTree(partitioner, range, RECOMMENDED_DEPTH, 16);
+ ltree.init();
+ MerkleTree rtree = new MerkleTree(partitioner, range, RECOMMENDED_DEPTH, 16);
+ rtree.init();
+
+ byte[] h1 = "asdf".getBytes();
+ byte[] h2 = "asdf".getBytes();
+
+
+ // add dummy hashes to both trees
+ for (TreeRange tree : ltree.invalids())
+ {
+ tree.addHash(new RowHash(range.right, h1, h1.length));
+ }
+ for (TreeRange tree : rtree.invalids())
+ {
+ tree.addHash(new RowHash(range.right, h2, h2.length));
+ }
+
+ // top level difference() should show no differences
+ assertEquals(MerkleTree.difference(ltree, rtree), Lists.newArrayList());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[6/6] cassandra git commit: Merge branch 'cassandra-3.11' into trunk
Posted by jj...@apache.org.
Merge branch 'cassandra-3.11' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/dcef7c7e
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/dcef7c7e
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/dcef7c7e
Branch: refs/heads/trunk
Commit: dcef7c7ed9bac3484322ed5b20eaa20d373833e7
Parents: fa36044 90b39dc
Author: Jeff Jirsa <jj...@apple.com>
Authored: Tue Sep 5 11:59:35 2017 -0700
Committer: Jeff Jirsa <jj...@apple.com>
Committed: Tue Sep 5 12:00:25 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/utils/MerkleTree.java | 23 +++++++++----
.../apache/cassandra/utils/MerkleTreeTest.java | 34 ++++++++++++++++++++
3 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/dcef7c7e/CHANGES.txt
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/dcef7c7e/src/java/org/apache/cassandra/utils/MerkleTree.java
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[4/6] cassandra git commit: Merge branch 'cassandra-3.0' into
cassandra-3.11
Posted by jj...@apache.org.
Merge branch 'cassandra-3.0' into cassandra-3.11
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/90b39dc6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/90b39dc6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/90b39dc6
Branch: refs/heads/trunk
Commit: 90b39dc619d75096e897fb8e90dd38b04e67f848
Parents: 3f5f702 bc5c231
Author: Jeff Jirsa <jj...@apple.com>
Authored: Tue Sep 5 11:58:31 2017 -0700
Committer: Jeff Jirsa <jj...@apple.com>
Committed: Tue Sep 5 11:59:25 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/utils/MerkleTree.java | 23 +++++++++----
.../apache/cassandra/utils/MerkleTreeTest.java | 34 ++++++++++++++++++++
3 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/90b39dc6/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 5a53e50,4302fdf..75d9bd6
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,14 -1,5 +1,15 @@@
-3.0.15
+3.11.1
+ * Add a compaction option to TWCS to ignore sstables overlapping checks (CASSANDRA-13418)
+ * BTree.Builder memory leak (CASSANDRA-13754)
+ * Revert CASSANDRA-10368 of supporting non-pk column filtering due to correctness (CASSANDRA-13798)
+ * Fix cassandra-stress hang issues when an error during cluster connection happens (CASSANDRA-12938)
+ * Better bootstrap failure message when blocked by (potential) range movement (CASSANDRA-13744)
+ * "ignore" option is ignored in sstableloader (CASSANDRA-13721)
+ * Deadlock in AbstractCommitLogSegmentManager (CASSANDRA-13652)
+ * Duplicate the buffer before passing it to analyser in SASI operation (CASSANDRA-13512)
+ * Properly evict pstmts from prepared statements cache (CASSANDRA-13641)
+Merged from 3.0:
+ * Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
* Better handle corrupt final commitlog segment (CASSANDRA-11995)
* StreamingHistogram is not thread safe (CASSANDRA-13756)
* Fix MV timestamp issues (CASSANDRA-11500)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/90b39dc6/src/java/org/apache/cassandra/utils/MerkleTree.java
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[5/6] cassandra git commit: Merge branch 'cassandra-3.0' into
cassandra-3.11
Posted by jj...@apache.org.
Merge branch 'cassandra-3.0' into cassandra-3.11
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/90b39dc6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/90b39dc6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/90b39dc6
Branch: refs/heads/cassandra-3.11
Commit: 90b39dc619d75096e897fb8e90dd38b04e67f848
Parents: 3f5f702 bc5c231
Author: Jeff Jirsa <jj...@apple.com>
Authored: Tue Sep 5 11:58:31 2017 -0700
Committer: Jeff Jirsa <jj...@apple.com>
Committed: Tue Sep 5 11:59:25 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/utils/MerkleTree.java | 23 +++++++++----
.../apache/cassandra/utils/MerkleTreeTest.java | 34 ++++++++++++++++++++
3 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/90b39dc6/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 5a53e50,4302fdf..75d9bd6
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,14 -1,5 +1,15 @@@
-3.0.15
+3.11.1
+ * Add a compaction option to TWCS to ignore sstables overlapping checks (CASSANDRA-13418)
+ * BTree.Builder memory leak (CASSANDRA-13754)
+ * Revert CASSANDRA-10368 of supporting non-pk column filtering due to correctness (CASSANDRA-13798)
+ * Fix cassandra-stress hang issues when an error during cluster connection happens (CASSANDRA-12938)
+ * Better bootstrap failure message when blocked by (potential) range movement (CASSANDRA-13744)
+ * "ignore" option is ignored in sstableloader (CASSANDRA-13721)
+ * Deadlock in AbstractCommitLogSegmentManager (CASSANDRA-13652)
+ * Duplicate the buffer before passing it to analyser in SASI operation (CASSANDRA-13512)
+ * Properly evict pstmts from prepared statements cache (CASSANDRA-13641)
+Merged from 3.0:
+ * Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
* Better handle corrupt final commitlog segment (CASSANDRA-11995)
* StreamingHistogram is not thread safe (CASSANDRA-13756)
* Fix MV timestamp issues (CASSANDRA-11500)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/90b39dc6/src/java/org/apache/cassandra/utils/MerkleTree.java
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
[3/6] cassandra git commit: Change repair midpoint logging for tiny
ranges
Posted by jj...@apache.org.
Change repair midpoint logging for tiny ranges
Patch by Jeff Jirsa; Reviewed by Blake Eggleston for CASSANDRA-13603
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bc5c2316
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bc5c2316
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bc5c2316
Branch: refs/heads/trunk
Commit: bc5c2316c5acfc1ee0ef101a3ebf00d03c89e283
Parents: 0493545
Author: Jeff Jirsa <jj...@apple.com>
Authored: Tue Sep 5 11:57:58 2017 -0700
Committer: Jeff Jirsa <jj...@apple.com>
Committed: Tue Sep 5 11:57:58 2017 -0700
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../org/apache/cassandra/utils/MerkleTree.java | 23 +++++++++----
.../apache/cassandra/utils/MerkleTreeTest.java | 34 ++++++++++++++++++++
3 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a3eccf2..4302fdf 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.15
+ * Change repair midpoint logging for tiny ranges (CASSANDRA-13603)
* Better handle corrupt final commitlog segment (CASSANDRA-11995)
* StreamingHistogram is not thread safe (CASSANDRA-13756)
* Fix MV timestamp issues (CASSANDRA-11500)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/src/java/org/apache/cassandra/utils/MerkleTree.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/MerkleTree.java b/src/java/org/apache/cassandra/utils/MerkleTree.java
index 0d5a469..22b61e8 100644
--- a/src/java/org/apache/cassandra/utils/MerkleTree.java
+++ b/src/java/org/apache/cassandra/utils/MerkleTree.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.*;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.PeekingIterator;
@@ -246,12 +247,20 @@ public class MerkleTree implements Serializable
if (lhash != null && rhash != null && !Arrays.equals(lhash, rhash))
{
- logger.debug("Digest mismatch detected, traversing trees [{}, {}]", ltree, rtree);
- if (FULLY_INCONSISTENT == differenceHelper(ltree, rtree, diff, active))
+ if(lnode instanceof Leaf || rnode instanceof Leaf)
{
- logger.debug("Range {} fully inconsistent", active);
+ logger.debug("Digest mismatch detected among leaf nodes {}, {}", lnode, rnode);
diff.add(active);
}
+ else
+ {
+ logger.debug("Digest mismatch detected, traversing trees [{}, {}]", ltree, rtree);
+ if (FULLY_INCONSISTENT == differenceHelper(ltree, rtree, diff, active))
+ {
+ logger.debug("Range {} fully inconsistent", active);
+ diff.add(active);
+ }
+ }
}
else if (lhash == null || rhash == null)
diff.add(active);
@@ -265,6 +274,7 @@ public class MerkleTree implements Serializable
* Takes two trees and a range for which they have hashes, but are inconsistent.
* @return FULLY_INCONSISTENT if active is inconsistent, PARTIALLY_INCONSISTENT if only a subrange is inconsistent.
*/
+ @VisibleForTesting
static int differenceHelper(MerkleTree ltree, MerkleTree rtree, List<TreeRange> diff, TreeRange active)
{
if (active.depth == Byte.MAX_VALUE)
@@ -274,10 +284,9 @@ public class MerkleTree implements Serializable
// sanity check for midpoint calculation, see CASSANDRA-13052
if (midpoint.equals(active.left) || midpoint.equals(active.right))
{
- // Unfortunately we can't throw here to abort the validation process, as the code is executed in it's own
- // thread with the caller waiting for a condition to be signaled after completion and without an option
- // to indicate an error (2.x only).
- logger.error("Invalid midpoint {} for [{},{}], range will be reported inconsistent", midpoint, active.left, active.right);
+ // If the midpoint equals either the left or the right, we have a range that's too small to split - we'll simply report the
+ // whole range as inconsistent
+ logger.debug("({}) No sane midpoint ({}) for range {} , marking whole range as inconsistent", active.depth, midpoint, active);
return FULLY_INCONSISTENT;
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/bc5c2316/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
index c9aa09f..64aea24 100644
--- a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
+++ b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
@@ -472,6 +472,40 @@ public class MerkleTreeTest
List<TreeRange> diffs = MerkleTree.difference(ltree, rtree);
assertEquals(Lists.newArrayList(range), diffs);
+ assertEquals(MerkleTree.FULLY_INCONSISTENT, MerkleTree.differenceHelper(ltree, rtree, new ArrayList<>(), new MerkleTree.TreeDifference(ltree.fullRange.left, ltree.fullRange.right, (byte)0)));
+ }
+
+ /**
+ * matching should behave as expected, even with extremely small ranges
+ */
+ @Test
+ public void matchingSmallRange()
+ {
+ Token start = new BigIntegerToken("9");
+ Token end = new BigIntegerToken("10");
+ Range<Token> range = new Range<>(start, end);
+
+ MerkleTree ltree = new MerkleTree(partitioner, range, RECOMMENDED_DEPTH, 16);
+ ltree.init();
+ MerkleTree rtree = new MerkleTree(partitioner, range, RECOMMENDED_DEPTH, 16);
+ rtree.init();
+
+ byte[] h1 = "asdf".getBytes();
+ byte[] h2 = "asdf".getBytes();
+
+
+ // add dummy hashes to both trees
+ for (TreeRange tree : ltree.invalids())
+ {
+ tree.addHash(new RowHash(range.right, h1, h1.length));
+ }
+ for (TreeRange tree : rtree.invalids())
+ {
+ tree.addHash(new RowHash(range.right, h2, h2.length));
+ }
+
+ // top level difference() should show no differences
+ assertEquals(MerkleTree.difference(ltree, rtree), Lists.newArrayList());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org