You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2016/05/26 16:38:41 UTC

[1/3] cassandra git commit: Avoid throwing WTE during commitlog replay due to MV lock contention

Repository: cassandra
Updated Branches:
  refs/heads/trunk bbc3834b1 -> 49278480d


Avoid throwing WTE during commitlog replay due to MV lock contention

Patch by Tyler Hobbs; reviewed by Jake Luciani for CASSANDRA-11891


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5794fb35
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5794fb35
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5794fb35

Branch: refs/heads/trunk
Commit: 5794fb3556a07a662a8a79cfd692eaa459e9066b
Parents: 764f3d3
Author: Tyler Hobbs <ty...@gmail.com>
Authored: Thu May 26 11:28:09 2016 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Thu May 26 11:28:09 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                    |  2 ++
 src/java/org/apache/cassandra/db/Keyspace.java | 12 +++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5794fb35/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75ce90d..97893c9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 3.0.7
+ * Avoid WriteTimeoutExceptions during commit log replay due to materialized
+   view lock contention (CASSANDRA-11891)
  * Prevent OOM failures on SSTable corruption, improve tests for corruption detection (CASSANDRA-9530)
  * Use CFS.initialDirectories when clearing snapshots (CASSANDRA-11705)
  * Allow compaction strategies to disable early open (CASSANDRA-11754)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5794fb35/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Keyspace.java b/src/java/org/apache/cassandra/db/Keyspace.java
index 5865364..8b23186 100644
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@ -423,7 +423,8 @@ public class Keyspace
 
             if (lock == null)
             {
-                if ((System.currentTimeMillis() - mutation.createdAt) > DatabaseDescriptor.getWriteRpcTimeout())
+                // avoid throwing a WTE during commitlog replay
+                if (!isClReplay && (System.currentTimeMillis() - mutation.createdAt) > DatabaseDescriptor.getWriteRpcTimeout())
                 {
                     logger.trace("Could not acquire lock for {}", ByteBufferUtil.bytesToHex(mutation.key().getKey()));
                     Tracing.trace("Could not acquire MV lock");
@@ -436,12 +437,9 @@ public class Keyspace
                 {
                     //This view update can't happen right now. so rather than keep this thread busy
                     // we will re-apply ourself to the queue and try again later
-                    StageManager.getStage(Stage.MUTATION).execute(() -> {
-                        if (writeCommitLog)
-                            apply(mutation, true, true, isClReplay, mark);
-                        else
-                            apply(mutation, false, true, isClReplay, mark);
-                    });
+                    StageManager.getStage(Stage.MUTATION).execute(() ->
+                        apply(mutation, writeCommitLog, true, isClReplay, mark)
+                    );
 
                     return mark;
                 }


[2/3] cassandra git commit: Merge branch 'cassandra-3.0' into cassandra-3.7

Posted by ty...@apache.org.
Merge branch 'cassandra-3.0' into cassandra-3.7

Conflicts:
	CHANGES.txt
	src/java/org/apache/cassandra/db/Keyspace.java


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f24e0667
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f24e0667
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f24e0667

Branch: refs/heads/trunk
Commit: f24e066754188c9c1298b17bb7cb40502655eb99
Parents: a40d2e2 5794fb3
Author: Tyler Hobbs <ty...@gmail.com>
Authored: Thu May 26 11:37:47 2016 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Thu May 26 11:37:47 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                    |  2 ++
 src/java/org/apache/cassandra/db/Keyspace.java | 12 +++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f24e0667/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 3acd3da,97893c9..79086b1
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,6 -1,6 +1,8 @@@
 -3.0.7
 +3.7
 + * Don't use static dataDirectories field in Directories instances (CASSANDRA-11647)
 +Merged from 3.0:
+  * Avoid WriteTimeoutExceptions during commit log replay due to materialized
+    view lock contention (CASSANDRA-11891)
   * Prevent OOM failures on SSTable corruption, improve tests for corruption detection (CASSANDRA-9530)
   * Use CFS.initialDirectories when clearing snapshots (CASSANDRA-11705)
   * Allow compaction strategies to disable early open (CASSANDRA-11754)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f24e0667/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/Keyspace.java
index 08317b4,8b23186..1b3418e
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@@ -434,45 -419,19 +434,43 @@@ public class Keyspac
          if (requiresViewUpdate)
          {
              mutation.viewLockAcquireStart.compareAndSet(0L, System.currentTimeMillis());
 -            lock = ViewManager.acquireLockFor(mutation.key().getKey());
  
 -            if (lock == null)
 +            // the order of lock acquisition doesn't matter (from a deadlock perspective) because we only use tryLock()
 +            Collection<UUID> columnFamilyIds = mutation.getColumnFamilyIds();
 +            Iterator<UUID> idIterator = columnFamilyIds.iterator();
 +            locks = new Lock[columnFamilyIds.size()];
 +
 +            for (int i = 0; i < columnFamilyIds.size(); i++)
              {
 -                // avoid throwing a WTE during commitlog replay
 -                if (!isClReplay && (System.currentTimeMillis() - mutation.createdAt) > DatabaseDescriptor.getWriteRpcTimeout())
 +                UUID cfid = idIterator.next();
 +                int lockKey = Objects.hash(mutation.key().getKey(), cfid);
 +                Lock lock = ViewManager.acquireLockFor(lockKey);
 +                if (lock == null)
                  {
 -                    logger.trace("Could not acquire lock for {}", ByteBufferUtil.bytesToHex(mutation.key().getKey()));
 -                    Tracing.trace("Could not acquire MV lock");
 -                    if (future != null)
 -                        future.completeExceptionally(new WriteTimeoutException(WriteType.VIEW, ConsistencyLevel.LOCAL_ONE, 0, 1));
 +                    // we will either time out or retry, so release all acquired locks
 +                    for (int j = 0; j < i; j++)
 +                        locks[j].unlock();
 +
-                     if ((System.currentTimeMillis() - mutation.createdAt) > DatabaseDescriptor.getWriteRpcTimeout())
++                    // avoid throwing a WTE during commitlog replay
++                    if (!isClReplay && (System.currentTimeMillis() - mutation.createdAt) > DatabaseDescriptor.getWriteRpcTimeout())
 +                    {
 +                        logger.trace("Could not acquire lock for {} and table {}", ByteBufferUtil.bytesToHex(mutation.key().getKey()), columnFamilyStores.get(cfid).name);
 +                        Tracing.trace("Could not acquire MV lock");
 +                        if (future != null)
 +                            future.completeExceptionally(new WriteTimeoutException(WriteType.VIEW, ConsistencyLevel.LOCAL_ONE, 0, 1));
 +                        else
 +                            throw new WriteTimeoutException(WriteType.VIEW, ConsistencyLevel.LOCAL_ONE, 0, 1);
 +                    }
                      else
 -                        throw new WriteTimeoutException(WriteType.VIEW, ConsistencyLevel.LOCAL_ONE, 0, 1);
 +                    {
 +                        // This view update can't happen right now. so rather than keep this thread busy
 +                        // we will re-apply ourself to the queue and try again later
-                         StageManager.getStage(Stage.MUTATION).execute(() -> {
-                             if (writeCommitLog)
-                                 apply(mutation, true, true, isClReplay, mark);
-                             else
-                                 apply(mutation, false, true, isClReplay, mark);
-                         });
++                        StageManager.getStage(Stage.MUTATION).execute(() ->
++                            apply(mutation, writeCommitLog, true, isClReplay, mark)
++                        );
 +
 +                        return mark;
 +                    }
                  }
                  else
                  {


[3/3] cassandra git commit: Merge branch 'cassandra-3.7' into trunk

Posted by ty...@apache.org.
Merge branch 'cassandra-3.7' into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/49278480
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/49278480
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/49278480

Branch: refs/heads/trunk
Commit: 49278480d9d990e25f8ae7d939e5fd92d87864e8
Parents: bbc3834 f24e066
Author: Tyler Hobbs <ty...@gmail.com>
Authored: Thu May 26 11:37:59 2016 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Thu May 26 11:37:59 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                    |  2 ++
 src/java/org/apache/cassandra/db/Keyspace.java | 12 +++++-------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/49278480/CHANGES.txt
----------------------------------------------------------------------