You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2014/09/30 21:11:17 UTC

[1/6] git commit: Archive any commitlog segments present at startup patch by Sam Tunnicliffe; reviewed by bes and jbellis for CASSANDRA-6904

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 aa7794c83 -> 7bff18357
  refs/heads/cassandra-2.1 ef65d5821 -> 1394b128c
  refs/heads/trunk c5c3ee926 -> 6b849da26


Archive any commitlog segments present at startup
patch by Sam Tunnicliffe; reviewed by bes and jbellis for CASSANDRA-6904


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

Branch: refs/heads/cassandra-2.0
Commit: 7bff18357e1e9227c13016b1c5b5e1a71db4f811
Parents: aa7794c
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Sep 30 14:08:16 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Sep 30 14:08:16 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |  4 ++++
 .../apache/cassandra/db/commitlog/CommitLog.java   | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7bff1835/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5902d75..6f59a29 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+2.0.12:
+ * Archive any commitlog segments present at startup (CASSANDRA-6904)
+
+
 2.0.11:
  * Ignore fat clients when checking for endpoint collision (CASSANDRA-7939)
  * CrcCheckChance should adjust based on live CFMetadata not 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7bff1835/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 4bab83f..0e2f5bf 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
@@ -106,9 +106,7 @@ public class CommitLog implements CommitLogMBean
      */
     public int recover() throws IOException
     {
-        archiver.maybeRestoreArchive();
-
-        File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(new FilenameFilter()
+        FilenameFilter unmanagedFilesFilter = new FilenameFilter()
         {
             public boolean accept(File dir, String name)
             {
@@ -117,8 +115,19 @@ public class CommitLog implements CommitLogMBean
                 // ahead and allow writes before recover(), and just skip active segments when we do.
                 return CommitLogDescriptor.isValid(name) && !instance.allocator.manages(name);
             }
-        });
+        };
+
+        // submit all existing files in the commit log dir for archiving prior to recovery - CASSANDRA-6904
+        for (File file : new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter))
+        {
+            archiver.maybeArchive(file.getPath(), file.getName());
+            archiver.maybeWaitForArchiving(file.getName());
+        }
+
+        assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore";
+        archiver.maybeRestoreArchive();
 
+        File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter);
         int replayed = 0;
         if (files.length == 0)
         {


[6/6] git commit: Merge branch 'cassandra-2.1' into trunk

Posted by jb...@apache.org.
Merge branch 'cassandra-2.1' into trunk


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

Branch: refs/heads/trunk
Commit: 6b849da26df6bd1e99f6379a814691d43a2d6d0c
Parents: c5c3ee9 1394b12
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Sep 30 14:11:09 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Sep 30 14:11:09 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/db/commitlog/CommitLog.java       | 17 +++++++++---
 .../db/commitlog/CommitLogArchiver.java         | 28 +++++++++++++++++++-
 3 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


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

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


[2/6] git commit: Archive any commitlog segments present at startup patch by Sam Tunnicliffe; reviewed by bes and jbellis for CASSANDRA-6904

Posted by jb...@apache.org.
Archive any commitlog segments present at startup
patch by Sam Tunnicliffe; reviewed by bes and jbellis for CASSANDRA-6904


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

Branch: refs/heads/cassandra-2.1
Commit: 7bff18357e1e9227c13016b1c5b5e1a71db4f811
Parents: aa7794c
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Sep 30 14:08:16 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Sep 30 14:08:16 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |  4 ++++
 .../apache/cassandra/db/commitlog/CommitLog.java   | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7bff1835/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5902d75..6f59a29 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+2.0.12:
+ * Archive any commitlog segments present at startup (CASSANDRA-6904)
+
+
 2.0.11:
  * Ignore fat clients when checking for endpoint collision (CASSANDRA-7939)
  * CrcCheckChance should adjust based on live CFMetadata not 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7bff1835/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 4bab83f..0e2f5bf 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
@@ -106,9 +106,7 @@ public class CommitLog implements CommitLogMBean
      */
     public int recover() throws IOException
     {
-        archiver.maybeRestoreArchive();
-
-        File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(new FilenameFilter()
+        FilenameFilter unmanagedFilesFilter = new FilenameFilter()
         {
             public boolean accept(File dir, String name)
             {
@@ -117,8 +115,19 @@ public class CommitLog implements CommitLogMBean
                 // ahead and allow writes before recover(), and just skip active segments when we do.
                 return CommitLogDescriptor.isValid(name) && !instance.allocator.manages(name);
             }
-        });
+        };
+
+        // submit all existing files in the commit log dir for archiving prior to recovery - CASSANDRA-6904
+        for (File file : new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter))
+        {
+            archiver.maybeArchive(file.getPath(), file.getName());
+            archiver.maybeWaitForArchiving(file.getName());
+        }
+
+        assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore";
+        archiver.maybeRestoreArchive();
 
+        File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter);
         int replayed = 0;
         if (files.length == 0)
         {


[5/6] git commit: merge from 2.0

Posted by jb...@apache.org.
merge from 2.0


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

Branch: refs/heads/cassandra-2.1
Commit: 1394b128c65ef1ad59f765e9c9c5058cac04ca69
Parents: ef65d58 7bff183
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Sep 30 14:08:29 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Sep 30 14:10:11 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/db/commitlog/CommitLog.java       | 17 +++++++++---
 .../db/commitlog/CommitLogArchiver.java         | 28 +++++++++++++++++++-
 3 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1394b128/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 9881a94,6f59a29..3c217e2
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,55 -1,9 +1,56 @@@
 -2.0.12:
 - * Archive any commitlog segments present at startup (CASSANDRA-6904)
 -
 -
 -2.0.11:
 +2.1.1
   * Ignore fat clients when checking for endpoint collision (CASSANDRA-7939)
 + * Make sstablerepairedset take a list of files (CASSANDRA-7995)
 + * (cqlsh) Tab completeion for indexes on map keys (CASSANDRA-7972)
 + * (cqlsh) Fix UDT field selection in select clause (CASSANDRA-7891)
 + * Fix resource leak in event of corrupt sstable
 + * (cqlsh) Add command line option for cqlshrc file path (CASSANDRA-7131)
 + * Provide visibility into prepared statements churn (CASSANDRA-7921, CASSANDRA-7930)
 + * Invalidate prepared statements when their keyspace or table is
 +   dropped (CASSANDRA-7566)
 + * cassandra-stress: fix support for NetworkTopologyStrategy (CASSANDRA-7945)
 + * Fix saving caches when a table is dropped (CASSANDRA-7784)
 + * Add better error checking of new stress profile (CASSANDRA-7716)
 + * Use ThreadLocalRandom and remove FBUtilities.threadLocalRandom (CASSANDRA-7934)
 + * Prevent operator mistakes due to simultaneous bootstrap (CASSANDRA-7069)
 + * cassandra-stress supports whitelist mode for node config (CASSANDRA-7658)
 + * GCInspector more closely tracks GC; cassandra-stress and nodetool report it (CASSANDRA-7916)
 + * nodetool won't output bogus ownership info without a keyspace (CASSANDRA-7173)
 + * Add human readable option to nodetool commands (CASSANDRA-5433)
 + * Don't try to set repairedAt on old sstables (CASSANDRA-7913)
 + * Add metrics for tracking PreparedStatement use (CASSANDRA-7719)
 + * (cqlsh) tab-completion for triggers (CASSANDRA-7824)
 + * (cqlsh) Support for query paging (CASSANDRA-7514)
 + * (cqlsh) Show progress of COPY operations (CASSANDRA-7789)
 + * Add syntax to remove multiple elements from a map (CASSANDRA-6599)
 + * Support non-equals conditions in lightweight transactions (CASSANDRA-6839)
 + * Add IF [NOT] EXISTS to create/drop triggers (CASSANDRA-7606)
 + * (cqlsh) Display the current logged-in user (CASSANDRA-7785)
 + * (cqlsh) Don't ignore CTRL-C during COPY FROM execution (CASSANDRA-7815)
 + * (cqlsh) Order UDTs according to cross-type dependencies in DESCRIBE
 +   output (CASSANDRA-7659)
 + * (cqlsh) Fix handling of CAS statement results (CASSANDRA-7671)
 + * (cqlsh) COPY TO/FROM improvements (CASSANDRA-7405)
 + * Support list index operations with conditions (CASSANDRA-7499)
 + * Add max live/tombstoned cells to nodetool cfstats output (CASSANDRA-7731)
 + * Validate IPv6 wildcard addresses properly (CASSANDRA-7680)
 + * (cqlsh) Error when tracing query (CASSANDRA-7613)
 + * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569)
 + * SSTableExport uses correct validator to create string representation of partition
 +   keys (CASSANDRA-7498)
 + * Avoid NPEs when receiving type changes for an unknown keyspace (CASSANDRA-7689)
 + * Add support for custom 2i validation (CASSANDRA-7575)
 + * Pig support for hadoop CqlInputFormat (CASSANDRA-6454)
 + * Add listen_interface and rpc_interface options (CASSANDRA-7417)
 + * Improve schema merge performance (CASSANDRA-7444)
 + * Adjust MT depth based on # of partition validating (CASSANDRA-5263)
 + * Optimise NativeCell comparisons (CASSANDRA-6755)
 + * Configurable client timeout for cqlsh (CASSANDRA-7516)
 + * Include snippet of CQL query near syntax error in messages (CASSANDRA-7111)
 + * Make repair -pr work with -local (CASSANDRA-7450)
 + * Fix error in sstableloader with -cph > 1 (CASSANDRA-8007)
 +Merged from 2.0:
++ * Archive any commitlog segments present at startup (CASSANDRA-6904)
   * CrcCheckChance should adjust based on live CFMetadata not 
     sstable metadata (CASSANDRA-7978)
   * token() should only accept columns in the partitioning

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

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1394b128/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
index 2795cae,f020182..c385f75
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
@@@ -103,23 -103,22 +103,45 @@@ public class CommitLogArchive
          }
      }
  
 +    public void maybeArchive(final CommitLogSegment segment)
 +    {
 +        if (Strings.isNullOrEmpty(archiveCommand))
 +            return;
 +
 +        archivePending.put(segment.getName(), executor.submit(new WrappedRunnable()
 +        {
 +            protected void runMayThrow() throws IOException
 +            {
 +                segment.waitForFinalSync();
 +                String command = archiveCommand.replace("%name", segment.getName());
 +                command = command.replace("%path", segment.getPath());
 +                exec(command);
 +            }
 +        }));
 +    }
 +
++    /**
++     * Differs from the above because it can be used on any file, rather than only
++     * managed commit log segments (and thus cannot call waitForFinalSync).
++     *
++     * Used to archive files present in the commit log directory at startup (CASSANDRA-6904)
++     */
+     public void maybeArchive(final String path, final String name)
+     {
+         if (Strings.isNullOrEmpty(archiveCommand))
+             return;
+ 
+         archivePending.put(name, executor.submit(new WrappedRunnable()
+         {
+             protected void runMayThrow() throws IOException
+             {
+                 String command = archiveCommand.replace("%name", name);
+                 command = command.replace("%path", path);
+                 exec(command);
+             }
+         }));
+     }
+ 
      public boolean maybeWaitForArchiving(String name)
      {
          Future<?> f = archivePending.remove(name);
@@@ -161,26 -160,7 +183,30 @@@
              }
              for (File fromFile : files)
              {
 -                File toFile = new File(DatabaseDescriptor.getCommitLogLocation(), new CommitLogDescriptor(CommitLogSegment.getNextId()).fileName());
 +                CommitLogDescriptor fromHeader = CommitLogDescriptor.fromHeader(fromFile);
 +                CommitLogDescriptor fromName = CommitLogDescriptor.isValid(fromFile.getName()) ? CommitLogDescriptor.fromFileName(fromFile.getName()) : null;
 +                CommitLogDescriptor descriptor;
 +                if (fromHeader == null && fromName == null)
 +                    throw new IllegalStateException("Cannot safely construct descriptor for segment, either from its name or its header: " + fromFile.getPath());
 +                else if (fromHeader != null && fromName != null && !fromHeader.equals(fromName))
 +                    throw new IllegalStateException(String.format("Cannot safely construct descriptor for segment, as name and header descriptors do not match (%s vs %s): %s", fromHeader, fromName, fromFile.getPath()));
 +                else if (fromName != null && fromHeader == null && fromName.version >= CommitLogDescriptor.VERSION_21)
 +                    throw new IllegalStateException("Cannot safely construct descriptor for segment, as name descriptor implies a version that should contain a header descriptor, but that descriptor could not be read: " + fromFile.getPath());
 +                else if (fromHeader != null)
 +                    descriptor = fromHeader;
 +                else descriptor = fromName;
 +
 +                if (descriptor.version > CommitLogDescriptor.VERSION_21)
 +                    throw new IllegalStateException("Unsupported commit log version: " + descriptor.version);
 +
 +                File toFile = new File(DatabaseDescriptor.getCommitLogLocation(), descriptor.fileName());
 +                if (toFile.exists())
-                     throw new IllegalStateException("Trying to restore archive " + fromFile.getPath() + ", but the same segment already exists in the restore location: " + toFile.getPath());
++                {
++                    logger.debug("Skipping restore of archive {} as the segment already exists in the restore location {}",
++                                 fromFile.getPath(), toFile.getPath());
++                    continue;
++                }
 +
                  String command = restoreCommand.replace("%from", fromFile.getPath());
                  command = command.replace("%to", toFile.getPath());
                  try


[3/6] git commit: Archive any commitlog segments present at startup patch by Sam Tunnicliffe; reviewed by bes and jbellis for CASSANDRA-6904

Posted by jb...@apache.org.
Archive any commitlog segments present at startup
patch by Sam Tunnicliffe; reviewed by bes and jbellis for CASSANDRA-6904


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

Branch: refs/heads/trunk
Commit: 7bff18357e1e9227c13016b1c5b5e1a71db4f811
Parents: aa7794c
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Sep 30 14:08:16 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Sep 30 14:08:16 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |  4 ++++
 .../apache/cassandra/db/commitlog/CommitLog.java   | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7bff1835/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5902d75..6f59a29 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+2.0.12:
+ * Archive any commitlog segments present at startup (CASSANDRA-6904)
+
+
 2.0.11:
  * Ignore fat clients when checking for endpoint collision (CASSANDRA-7939)
  * CrcCheckChance should adjust based on live CFMetadata not 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7bff1835/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 4bab83f..0e2f5bf 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
@@ -106,9 +106,7 @@ public class CommitLog implements CommitLogMBean
      */
     public int recover() throws IOException
     {
-        archiver.maybeRestoreArchive();
-
-        File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(new FilenameFilter()
+        FilenameFilter unmanagedFilesFilter = new FilenameFilter()
         {
             public boolean accept(File dir, String name)
             {
@@ -117,8 +115,19 @@ public class CommitLog implements CommitLogMBean
                 // ahead and allow writes before recover(), and just skip active segments when we do.
                 return CommitLogDescriptor.isValid(name) && !instance.allocator.manages(name);
             }
-        });
+        };
+
+        // submit all existing files in the commit log dir for archiving prior to recovery - CASSANDRA-6904
+        for (File file : new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter))
+        {
+            archiver.maybeArchive(file.getPath(), file.getName());
+            archiver.maybeWaitForArchiving(file.getName());
+        }
+
+        assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore";
+        archiver.maybeRestoreArchive();
 
+        File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter);
         int replayed = 0;
         if (files.length == 0)
         {


[4/6] git commit: merge from 2.0

Posted by jb...@apache.org.
merge from 2.0


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

Branch: refs/heads/trunk
Commit: 1394b128c65ef1ad59f765e9c9c5058cac04ca69
Parents: ef65d58 7bff183
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Sep 30 14:08:29 2014 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Sep 30 14:10:11 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/db/commitlog/CommitLog.java       | 17 +++++++++---
 .../db/commitlog/CommitLogArchiver.java         | 28 +++++++++++++++++++-
 3 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1394b128/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 9881a94,6f59a29..3c217e2
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,55 -1,9 +1,56 @@@
 -2.0.12:
 - * Archive any commitlog segments present at startup (CASSANDRA-6904)
 -
 -
 -2.0.11:
 +2.1.1
   * Ignore fat clients when checking for endpoint collision (CASSANDRA-7939)
 + * Make sstablerepairedset take a list of files (CASSANDRA-7995)
 + * (cqlsh) Tab completeion for indexes on map keys (CASSANDRA-7972)
 + * (cqlsh) Fix UDT field selection in select clause (CASSANDRA-7891)
 + * Fix resource leak in event of corrupt sstable
 + * (cqlsh) Add command line option for cqlshrc file path (CASSANDRA-7131)
 + * Provide visibility into prepared statements churn (CASSANDRA-7921, CASSANDRA-7930)
 + * Invalidate prepared statements when their keyspace or table is
 +   dropped (CASSANDRA-7566)
 + * cassandra-stress: fix support for NetworkTopologyStrategy (CASSANDRA-7945)
 + * Fix saving caches when a table is dropped (CASSANDRA-7784)
 + * Add better error checking of new stress profile (CASSANDRA-7716)
 + * Use ThreadLocalRandom and remove FBUtilities.threadLocalRandom (CASSANDRA-7934)
 + * Prevent operator mistakes due to simultaneous bootstrap (CASSANDRA-7069)
 + * cassandra-stress supports whitelist mode for node config (CASSANDRA-7658)
 + * GCInspector more closely tracks GC; cassandra-stress and nodetool report it (CASSANDRA-7916)
 + * nodetool won't output bogus ownership info without a keyspace (CASSANDRA-7173)
 + * Add human readable option to nodetool commands (CASSANDRA-5433)
 + * Don't try to set repairedAt on old sstables (CASSANDRA-7913)
 + * Add metrics for tracking PreparedStatement use (CASSANDRA-7719)
 + * (cqlsh) tab-completion for triggers (CASSANDRA-7824)
 + * (cqlsh) Support for query paging (CASSANDRA-7514)
 + * (cqlsh) Show progress of COPY operations (CASSANDRA-7789)
 + * Add syntax to remove multiple elements from a map (CASSANDRA-6599)
 + * Support non-equals conditions in lightweight transactions (CASSANDRA-6839)
 + * Add IF [NOT] EXISTS to create/drop triggers (CASSANDRA-7606)
 + * (cqlsh) Display the current logged-in user (CASSANDRA-7785)
 + * (cqlsh) Don't ignore CTRL-C during COPY FROM execution (CASSANDRA-7815)
 + * (cqlsh) Order UDTs according to cross-type dependencies in DESCRIBE
 +   output (CASSANDRA-7659)
 + * (cqlsh) Fix handling of CAS statement results (CASSANDRA-7671)
 + * (cqlsh) COPY TO/FROM improvements (CASSANDRA-7405)
 + * Support list index operations with conditions (CASSANDRA-7499)
 + * Add max live/tombstoned cells to nodetool cfstats output (CASSANDRA-7731)
 + * Validate IPv6 wildcard addresses properly (CASSANDRA-7680)
 + * (cqlsh) Error when tracing query (CASSANDRA-7613)
 + * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569)
 + * SSTableExport uses correct validator to create string representation of partition
 +   keys (CASSANDRA-7498)
 + * Avoid NPEs when receiving type changes for an unknown keyspace (CASSANDRA-7689)
 + * Add support for custom 2i validation (CASSANDRA-7575)
 + * Pig support for hadoop CqlInputFormat (CASSANDRA-6454)
 + * Add listen_interface and rpc_interface options (CASSANDRA-7417)
 + * Improve schema merge performance (CASSANDRA-7444)
 + * Adjust MT depth based on # of partition validating (CASSANDRA-5263)
 + * Optimise NativeCell comparisons (CASSANDRA-6755)
 + * Configurable client timeout for cqlsh (CASSANDRA-7516)
 + * Include snippet of CQL query near syntax error in messages (CASSANDRA-7111)
 + * Make repair -pr work with -local (CASSANDRA-7450)
 + * Fix error in sstableloader with -cph > 1 (CASSANDRA-8007)
 +Merged from 2.0:
++ * Archive any commitlog segments present at startup (CASSANDRA-6904)
   * CrcCheckChance should adjust based on live CFMetadata not 
     sstable metadata (CASSANDRA-7978)
   * token() should only accept columns in the partitioning

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

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1394b128/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
index 2795cae,f020182..c385f75
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
@@@ -103,23 -103,22 +103,45 @@@ public class CommitLogArchive
          }
      }
  
 +    public void maybeArchive(final CommitLogSegment segment)
 +    {
 +        if (Strings.isNullOrEmpty(archiveCommand))
 +            return;
 +
 +        archivePending.put(segment.getName(), executor.submit(new WrappedRunnable()
 +        {
 +            protected void runMayThrow() throws IOException
 +            {
 +                segment.waitForFinalSync();
 +                String command = archiveCommand.replace("%name", segment.getName());
 +                command = command.replace("%path", segment.getPath());
 +                exec(command);
 +            }
 +        }));
 +    }
 +
++    /**
++     * Differs from the above because it can be used on any file, rather than only
++     * managed commit log segments (and thus cannot call waitForFinalSync).
++     *
++     * Used to archive files present in the commit log directory at startup (CASSANDRA-6904)
++     */
+     public void maybeArchive(final String path, final String name)
+     {
+         if (Strings.isNullOrEmpty(archiveCommand))
+             return;
+ 
+         archivePending.put(name, executor.submit(new WrappedRunnable()
+         {
+             protected void runMayThrow() throws IOException
+             {
+                 String command = archiveCommand.replace("%name", name);
+                 command = command.replace("%path", path);
+                 exec(command);
+             }
+         }));
+     }
+ 
      public boolean maybeWaitForArchiving(String name)
      {
          Future<?> f = archivePending.remove(name);
@@@ -161,26 -160,7 +183,30 @@@
              }
              for (File fromFile : files)
              {
 -                File toFile = new File(DatabaseDescriptor.getCommitLogLocation(), new CommitLogDescriptor(CommitLogSegment.getNextId()).fileName());
 +                CommitLogDescriptor fromHeader = CommitLogDescriptor.fromHeader(fromFile);
 +                CommitLogDescriptor fromName = CommitLogDescriptor.isValid(fromFile.getName()) ? CommitLogDescriptor.fromFileName(fromFile.getName()) : null;
 +                CommitLogDescriptor descriptor;
 +                if (fromHeader == null && fromName == null)
 +                    throw new IllegalStateException("Cannot safely construct descriptor for segment, either from its name or its header: " + fromFile.getPath());
 +                else if (fromHeader != null && fromName != null && !fromHeader.equals(fromName))
 +                    throw new IllegalStateException(String.format("Cannot safely construct descriptor for segment, as name and header descriptors do not match (%s vs %s): %s", fromHeader, fromName, fromFile.getPath()));
 +                else if (fromName != null && fromHeader == null && fromName.version >= CommitLogDescriptor.VERSION_21)
 +                    throw new IllegalStateException("Cannot safely construct descriptor for segment, as name descriptor implies a version that should contain a header descriptor, but that descriptor could not be read: " + fromFile.getPath());
 +                else if (fromHeader != null)
 +                    descriptor = fromHeader;
 +                else descriptor = fromName;
 +
 +                if (descriptor.version > CommitLogDescriptor.VERSION_21)
 +                    throw new IllegalStateException("Unsupported commit log version: " + descriptor.version);
 +
 +                File toFile = new File(DatabaseDescriptor.getCommitLogLocation(), descriptor.fileName());
 +                if (toFile.exists())
-                     throw new IllegalStateException("Trying to restore archive " + fromFile.getPath() + ", but the same segment already exists in the restore location: " + toFile.getPath());
++                {
++                    logger.debug("Skipping restore of archive {} as the segment already exists in the restore location {}",
++                                 fromFile.getPath(), toFile.getPath());
++                    continue;
++                }
 +
                  String command = restoreCommand.replace("%from", fromFile.getPath());
                  command = command.replace("%to", toFile.getPath());
                  try