cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/2] git commit: back up new sstables before creating a new View (which makes the new one eligible for compaction)
Date Thu, 04 Apr 2013 21:42:35 GMT
Updated Branches:
  refs/heads/trunk 3bef1ccac -> e37ca25cf


back up new sstables before creating a new View (which makes the new one eligible for compaction)

patch by jbellis, reviewed by marcuse for CASSANDRA-5410


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

Branch: refs/heads/trunk
Commit: 8a422179c0a0a50e4d4b2e9274cbaf7259e90b2a
Parents: 698fc44
Author: Marcus Eriksson <marcuse@spotify.com>
Authored: Thu Apr 4 23:38:00 2013 +0200
Committer: Marcus Eriksson <marcuse@spotify.com>
Committed: Thu Apr 4 23:38:00 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |    1 +
 src/java/org/apache/cassandra/db/DataTracker.java |   21 ++++++----------
 2 files changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a422179/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 047bf93..8bcde57 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -29,6 +29,7 @@
  * cqlsh: Print maps ordered by key, sort sets (CASSANDRA-5413)
  * Add null syntax support in CQL3 for inserts (CASSANDRA-3783)
  * Allow unauthenticated set_keyspace() calls (CASSANDRA-5423)
+ * Fix potential incremental backups race (CASSANDRA-5410)
 Merged from 1.1:
  * cli: Quote ks and cf names in schema output when needed (CASSANDRA-5052)
  * Fix bad default for min/max timestamp in SSTableMetadata (CASSANDRA-5372)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8a422179/src/java/org/apache/cassandra/db/DataTracker.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DataTracker.java b/src/java/org/apache/cassandra/db/DataTracker.java
index b6bcebd..adbe037 100644
--- a/src/java/org/apache/cassandra/db/DataTracker.java
+++ b/src/java/org/apache/cassandra/db/DataTracker.java
@@ -35,7 +35,6 @@ import org.apache.cassandra.notifications.INotification;
 import org.apache.cassandra.notifications.INotificationConsumer;
 import org.apache.cassandra.notifications.SSTableAddedNotification;
 import org.apache.cassandra.notifications.SSTableListChangedNotification;
-import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.Interval;
 import org.apache.cassandra.utils.IntervalTree;
 
@@ -139,6 +138,10 @@ public class DataTracker
             return;
         }
 
+        // back up before creating a new View (which makes the new one eligible for compaction)
+        if (sstable != null)
+            maybeIncrementallyBackup(sstable);
+
         View currentView, newView;
         do
         {
@@ -151,24 +154,16 @@ public class DataTracker
         {
             addNewSSTablesSize(Arrays.asList(sstable));
             notifyAdded(sstable);
-            incrementallyBackup(sstable);
         }
     }
 
-    public void incrementallyBackup(final SSTableReader sstable)
+    public void maybeIncrementallyBackup(final SSTableReader sstable)
     {
         if (!DatabaseDescriptor.isIncrementalBackupsEnabled())
             return;
 
-        Runnable runnable = new Runnable()
-        {
-            public void run()
-            {
-                File backupsDir = Directories.getBackupsDirectory(sstable.descriptor);
-                sstable.createLinks(FileUtils.getCanonicalPath(backupsDir));
-            }
-        };
-        StorageService.tasks.execute(runnable);
+        File backupsDir = Directories.getBackupsDirectory(sstable.descriptor);
+        sstable.createLinks(FileUtils.getCanonicalPath(backupsDir));
     }
 
     /**
@@ -239,7 +234,7 @@ public class DataTracker
         replace(Collections.<SSTableReader>emptyList(), sstables);
         for (SSTableReader sstable : sstables)
         {
-            incrementallyBackup(sstable);
+            maybeIncrementallyBackup(sstable);
             notifyAdded(sstable);
         }
     }


Mime
View raw message