You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/03/19 19:51:48 UTC

[cassandra] branch trunk updated (111f1da -> 1a735f3)

This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from 111f1da  Merge branch 'CASSANDRA-14904' into trunk
     new 731dfda  Fixed empty check in TrieMemIndex due to potential state inconsistency in ConcurrentSkipListMap
     new 1a735f3  Fixed flakey test in SASIIndexTest by shutting down its ExecutorService

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.txt                                        |  2 ++
 .../index/sasi/memory/KeyRangeIterator.java        |  4 +--
 .../index/sasi/memory/SkipListMemIndex.java        |  9 ++++--
 .../cassandra/index/sasi/memory/TrieMemIndex.java  |  5 ++--
 .../apache/cassandra/index/sasi/SASIIndexTest.java | 35 ++++++++++++----------
 5 files changed, 33 insertions(+), 22 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


[cassandra] 01/02: Fixed empty check in TrieMemIndex due to potential state inconsistency in ConcurrentSkipListMap

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 731dfda99249c9b64fca5fa258c6078bfbe040ac
Author: Gianluca Righetto <gi...@menttis.com>
AuthorDate: Wed Mar 18 15:42:44 2020 -0300

    Fixed empty check in TrieMemIndex due to potential state inconsistency in ConcurrentSkipListMap
    
    Patch by Gianluca Righetto, reviewed by Ekaterina Dimitrova and Zhao Yang for  CASSANDRA-15526
---
 CHANGES.txt                                                      | 1 +
 .../org/apache/cassandra/index/sasi/memory/KeyRangeIterator.java | 4 ++--
 .../org/apache/cassandra/index/sasi/memory/SkipListMemIndex.java | 9 ++++++---
 .../org/apache/cassandra/index/sasi/memory/TrieMemIndex.java     | 5 +++--
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 508ae19..8c8e74b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-alpha4
+ * Fixed empty check in TrieMemIndex due to potential state inconsistency in ConcurrentSkipListMap (CASSANDRA-15526)
  * Add compaction allocation measurement test (CASSANDRA-15388)
  * Added UnleveledSSTables global and table level metric (CASSANDRA-15620)
  * Added Virtual Table exposing Cassandra relevant system properties (CASSANDRA-15616, CASSANDRA-15643)
diff --git a/src/java/org/apache/cassandra/index/sasi/memory/KeyRangeIterator.java b/src/java/org/apache/cassandra/index/sasi/memory/KeyRangeIterator.java
index 59d1122..0f681b7 100644
--- a/src/java/org/apache/cassandra/index/sasi/memory/KeyRangeIterator.java
+++ b/src/java/org/apache/cassandra/index/sasi/memory/KeyRangeIterator.java
@@ -37,9 +37,9 @@ public class KeyRangeIterator extends RangeIterator<Long, Token>
 {
     private final DKIterator iterator;
 
-    public KeyRangeIterator(ConcurrentSkipListSet<DecoratedKey> keys)
+    public KeyRangeIterator(ConcurrentSkipListSet<DecoratedKey> keys, int size)
     {
-        super((Long) keys.first().getToken().getTokenValue(), (Long) keys.last().getToken().getTokenValue(), keys.size());
+        super((Long) keys.first().getToken().getTokenValue(), (Long) keys.last().getToken().getTokenValue(), size);
         this.iterator = new DKIterator(keys.iterator());
     }
 
diff --git a/src/java/org/apache/cassandra/index/sasi/memory/SkipListMemIndex.java b/src/java/org/apache/cassandra/index/sasi/memory/SkipListMemIndex.java
index 69b57d0..9e44344 100644
--- a/src/java/org/apache/cassandra/index/sasi/memory/SkipListMemIndex.java
+++ b/src/java/org/apache/cassandra/index/sasi/memory/SkipListMemIndex.java
@@ -88,9 +88,12 @@ public class SkipListMemIndex extends MemIndex
         }
 
         RangeUnionIterator.Builder<Long, Token> builder = RangeUnionIterator.builder();
-        search.values().stream()
-                       .filter(keys -> !keys.isEmpty())
-                       .forEach(keys -> builder.add(new KeyRangeIterator(keys)));
+
+        for (ConcurrentSkipListSet<DecoratedKey> keys : search.values()) {
+            int size;
+            if ((size = keys.size()) > 0)
+                builder.add(new KeyRangeIterator(keys, size));
+        }
 
         return builder.build();
     }
diff --git a/src/java/org/apache/cassandra/index/sasi/memory/TrieMemIndex.java b/src/java/org/apache/cassandra/index/sasi/memory/TrieMemIndex.java
index 21cb7ce..cebd68f 100644
--- a/src/java/org/apache/cassandra/index/sasi/memory/TrieMemIndex.java
+++ b/src/java/org/apache/cassandra/index/sasi/memory/TrieMemIndex.java
@@ -146,8 +146,9 @@ public class TrieMemIndex extends MemIndex
             RangeUnionIterator.Builder<Long, Token> builder = RangeUnionIterator.builder();
             for (ConcurrentSkipListSet<DecoratedKey> keys : search)
             {
-                if (!keys.isEmpty())
-                    builder.add(new KeyRangeIterator(keys));
+                int size;
+                if ((size = keys.size()) > 0)
+                    builder.add(new KeyRangeIterator(keys, size));
             }
 
             return builder.build();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


[cassandra] 02/02: Fixed flakey test in SASIIndexTest by shutting down its ExecutorService

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 1a735f36b988157f1e7143852c4e3749649ee25d
Author: Gianluca Righetto <gi...@menttis.com>
AuthorDate: Fri Mar 6 03:45:17 2020 -0300

    Fixed flakey test in SASIIndexTest by shutting down its ExecutorService
    
    Patch by Gianluca Righetto, reviewed by Ekaterina Dimitrova and Zhao
    Yang for CASSANDRA-15528
---
 CHANGES.txt                                        |  1 +
 .../apache/cassandra/index/sasi/SASIIndexTest.java | 35 ++++++++++++----------
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 8c8e74b..9621128 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-alpha4
+ * Fixed flakey test in SASIIndexTest by shutting down its ExecutorService (CASSANDRA-15528)
  * Fixed empty check in TrieMemIndex due to potential state inconsistency in ConcurrentSkipListMap (CASSANDRA-15526)
  * Add compaction allocation measurement test (CASSANDRA-15388)
  * Added UnleveledSSTables global and table level metric (CASSANDRA-15620)
diff --git a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java
index 0be05b9..c64bec9 100644
--- a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java
@@ -1099,25 +1099,30 @@ public class SASIIndexTest
 
         int previousCount = 0;
 
-        do
+        try
         {
-            // this loop figures out if number of search results monotonically increasing
-            // to make sure that concurrent updates don't interfere with reads, uses first_name and age
-            // indexes to test correctness of both Trie and SkipList ColumnIndex implementations.
+            do
+            {
+                // this loop figures out if number of search results monotonically increasing
+                // to make sure that concurrent updates don't interfere with reads, uses first_name and age
+                // indexes to test correctness of both Trie and SkipList ColumnIndex implementations.
 
-            Set<DecoratedKey> rows = getPaged(store, 100, buildExpression(firstName, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")),
-                                                          buildExpression(age, Operator.EQ, Int32Type.instance.decompose(26)));
+                Set<DecoratedKey> rows = getPaged(store, 100, buildExpression(firstName, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")),
+                                                  buildExpression(age, Operator.EQ, Int32Type.instance.decompose(26)));
 
-            Assert.assertTrue(previousCount <= rows.size());
-            previousCount = rows.size();
-        }
-        while (updates.get() < writeCount);
-
-        // to make sure that after all of the writes are done we can read all "count" worth of rows
-        Set<DecoratedKey> rows = getPaged(store, 100, buildExpression(firstName, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")),
-                                                      buildExpression(age, Operator.EQ, Int32Type.instance.decompose(26)));
+                Assert.assertTrue(previousCount <= rows.size());
+                previousCount = rows.size();
+            }
+            while (updates.get() < writeCount);
 
-        Assert.assertEquals(writeCount, rows.size());
+            // to make sure that after all of the writes are done we can read all "count" worth of rows
+            Set<DecoratedKey> rows = getPaged(store, 100, buildExpression(firstName, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")),
+                            buildExpression(age, Operator.EQ, Int32Type.instance.decompose(26)));
+            Assert.assertEquals(writeCount, rows.size());
+        } finally {
+            scheduler.shutdownNow();
+            scheduler.awaitTermination(30, TimeUnit.SECONDS);
+        }
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org