You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2016/05/27 09:08:07 UTC

[1/2] cassandra git commit: Fix possible race condition in CommitLog.recover

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 5794fb355 -> 6f02446f3


Fix possible race condition in CommitLog.recover

patch by Benjamin Lerer; reviewed by Branimir Lambov for CASSANDRA-11743


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

Branch: refs/heads/cassandra-3.0
Commit: 6add3c9acc063005198510e9627ae9e783e54e91
Parents: 4aa859e
Author: Benjamin Lerer <b....@gmail.com>
Authored: Fri May 27 10:55:23 2016 +0200
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Fri May 27 10:55:23 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../apache/cassandra/db/commitlog/CommitLog.java    |  8 ++------
 .../cassandra/db/commitlog/CommitLogSegment.java    | 16 +++++++++++++++-
 3 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6add3c9a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f2276f0..7215836 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.7
+ * Fix possible race condition in CommitLog.recover (CASSANDRA-11743)
  * Enable client encryption in sstableloader with cli options (CASSANDRA-11708)
  * Possible memory leak in NIODataInputStream (CASSANDRA-11867)
  * Fix commit log replay after out-of-order flush completion (CASSANDRA-9669)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6add3c9a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
index 7592f48..9a6ba34 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
@@ -130,11 +130,6 @@ public class CommitLog implements CommitLogMBean
         if (allocator.createReserveSegments)
             return 0;
 
-        // Allocator could be in the process of initial startup with 0 active and available segments. We need to wait for
-        // the allocation manager to finish allocation and add it to available segments so we don't get an invalid response
-        // on allocator.manages(...) below by grabbing a file off the filesystem before it's added to the CLQ.
-        allocator.allocatingFrom();
-
         FilenameFilter unmanagedFilesFilter = new FilenameFilter()
         {
             public boolean accept(File dir, String name)
@@ -142,7 +137,7 @@ public class CommitLog implements CommitLogMBean
                 // we used to try to avoid instantiating commitlog (thus creating an empty segment ready for writes)
                 // until after recover was finished.  this turns out to be fragile; it is less error-prone to go
                 // ahead and allow writes before recover(), and just skip active segments when we do.
-                return CommitLogDescriptor.isValid(name) && !allocator.manages(name);
+                return CommitLogDescriptor.isValid(name) && CommitLogSegment.shouldReplay(name);
             }
         };
 
@@ -435,6 +430,7 @@ public class CommitLog implements CommitLogMBean
             throw new RuntimeException(e);
         }
         allocator.stopUnsafe(deleteSegments);
+        CommitLogSegment.resetReplayLimit();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6add3c9a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
index d748006..b6801d2 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
@@ -64,6 +64,7 @@ public abstract class CommitLogSegment
 
     private final static long idBase;
     private final static AtomicInteger nextId = new AtomicInteger(1);
+    private static long replayLimitId;
     static
     {
         long maxId = Long.MIN_VALUE;
@@ -72,7 +73,7 @@ public abstract class CommitLogSegment
             if (CommitLogDescriptor.isValid(file.getName()))
                 maxId = Math.max(CommitLogDescriptor.fromFileName(file.getName()).id, maxId);
         }
-        idBase = Math.max(System.currentTimeMillis(), maxId + 1);
+        replayLimitId = idBase = Math.max(System.currentTimeMillis(), maxId + 1);
     }
 
     // The commit log entry overhead in bytes (int: length + int: head checksum + int: tail checksum)
@@ -184,6 +185,19 @@ public abstract class CommitLogSegment
         }
     }
 
+    static boolean shouldReplay(String name)
+    {
+        return CommitLogDescriptor.fromFileName(name).id < replayLimitId;
+    }
+
+    /**
+     * FOR TESTING PURPOSES.
+     */
+    static void resetReplayLimit()
+    {
+        replayLimitId = getNextId();
+    }
+
     // allocate bytes in the segment, or return -1 if not enough space
     private int allocate(int size)
     {


[2/2] cassandra git commit: Merge branch cassandra-2.2 into cassandra-3.0

Posted by bl...@apache.org.
Merge branch cassandra-2.2 into cassandra-3.0


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

Branch: refs/heads/cassandra-3.0
Commit: 6f02446f3e09e0238c11bb7f63920ffba8a1d070
Parents: 5794fb3 6add3c9
Author: Benjamin Lerer <b....@gmail.com>
Authored: Fri May 27 11:07:26 2016 +0200
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Fri May 27 11:07:26 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../apache/cassandra/db/commitlog/CommitLog.java    |  8 ++------
 .../cassandra/db/commitlog/CommitLogSegment.java    | 16 +++++++++++++++-
 3 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f02446f/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 97893c9,7215836..3d166aa
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,47 -1,10 +1,48 @@@
 -2.2.7
 +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)
 + * Refactor Materialized View code (CASSANDRA-11475)
 + * Update Java Driver (CASSANDRA-11615)
 +Merged from 2.2:
+  * Fix possible race condition in CommitLog.recover (CASSANDRA-11743)
   * Enable client encryption in sstableloader with cli options (CASSANDRA-11708)
   * Possible memory leak in NIODataInputStream (CASSANDRA-11867)
 - * Fix commit log replay after out-of-order flush completion (CASSANDRA-9669)
   * Add seconds to cqlsh tracing session duration (CASSANDRA-11753)
 - * Prohibit Reverse Counter type as part of the PK (CASSANDRA-9395)
 + * Prohibit Reversed Counter type as part of the PK (CASSANDRA-9395)
 +Merged from 2.1:
 + * Backport CASSANDRA-11578 (CASSANDRA-11750)
 + * Clear out parent repair session if repair coordinator dies (CASSANDRA-11824)
 + * Set default streaming_socket_timeout_in_ms to 24 hours (CASSANDRA-11840)
 + * Do not consider local node a valid source during replace (CASSANDRA-11848)
 + * Add message dropped tasks to nodetool netstats (CASSANDRA-11855)
 + * Avoid holding SSTableReaders for duration of incremental repair (CASSANDRA-11739)
 +
 +
 +3.0.6
 + * Disallow creating view with a static column (CASSANDRA-11602)
 + * Reduce the amount of object allocations caused by the getFunctions methods (CASSANDRA-11593)
 + * Potential error replaying commitlog with smallint/tinyint/date/time types (CASSANDRA-11618)
 + * Fix queries with filtering on counter columns (CASSANDRA-11629)
 + * Improve tombstone printing in sstabledump (CASSANDRA-11655)
 + * Fix paging for range queries where all clustering columns are specified (CASSANDRA-11669)
 + * Don't require HEAP_NEW_SIZE to be set when using G1 (CASSANDRA-11600)
 + * Fix sstabledump not showing cells after tombstone marker (CASSANDRA-11654)
 + * Ignore all LocalStrategy keyspaces for streaming and other related
 +   operations (CASSANDRA-11627)
 + * Ensure columnfilter covers indexed columns for thrift 2i queries (CASSANDRA-11523)
 + * Only open one sstable scanner per sstable (CASSANDRA-11412)
 + * Option to specify ProtocolVersion in cassandra-stress (CASSANDRA-11410)
 + * ArithmeticException in avgFunctionForDecimal (CASSANDRA-11485)
 + * LogAwareFileLister should only use OLD sstable files in current folder to determine disk consistency (CASSANDRA-11470)
 + * Notify indexers of expired rows during compaction (CASSANDRA-11329)
 + * Properly respond with ProtocolError when a v1/v2 native protocol
 +   header is received (CASSANDRA-11464)
 + * Validate that num_tokens and initial_token are consistent with one another (CASSANDRA-10120)
 +Merged from 2.2:
 + * Fix commit log replay after out-of-order flush completion (CASSANDRA-9669)
   * cqlsh: correctly handle non-ascii chars in error messages (CASSANDRA-11626)
   * Exit JVM if JMX server fails to startup (CASSANDRA-11540)
   * Produce a heap dump when exiting on OOM (CASSANDRA-9861)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f02446f/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f02446f/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
----------------------------------------------------------------------