cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject cassandra git commit: avoid deleting non existing sstable files and improve related log messages
Date Tue, 30 Aug 2016 01:03:55 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 5db696339 -> 9ccccf28d


avoid deleting non existing sstable files and improve related log messages

patch by Stefania Alborghetti; reviewed by Benjamin Lerer for CASSANDRA-12261


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

Branch: refs/heads/trunk
Commit: 9ccccf28dc38ec932f9debcecbcb46f41a7f1ffe
Parents: 5db6963
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Thu Jul 28 11:12:48 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Tue Aug 30 09:02:57 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                       |  1 +
 .../apache/cassandra/db/lifecycle/LogFile.java    |  6 ++++++
 .../cassandra/db/lifecycle/LogTransaction.java    | 18 ++++++++++++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9ccccf28/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5d665b4..67f7786 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.10
+ * avoid deleting non existing sstable files and improve related log messages (CASSANDRA-12261)
  * json/yaml output format for nodetool compactionhistory (CASSANDRA-12486)
  * Retry all internode messages once after a connection is
    closed and reopened (CASSANDRA-12192)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9ccccf28/src/java/org/apache/cassandra/db/lifecycle/LogFile.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/lifecycle/LogFile.java b/src/java/org/apache/cassandra/db/lifecycle/LogFile.java
index a4f9869..f23613f 100644
--- a/src/java/org/apache/cassandra/db/lifecycle/LogFile.java
+++ b/src/java/org/apache/cassandra/db/lifecycle/LogFile.java
@@ -113,6 +113,12 @@ final class LogFile implements AutoCloseable
     {
         try
         {
+            // we sync the parent directories before content deletion to ensure
+            // any previously deleted files (see SSTableTider) are not
+            // incorrectly picked up by record.getExistingFiles() in
+            // deleteRecordFiles(), see CASSANDRA-12261
+            Throwables.maybeFail(syncDirectory(accumulate));
+
             deleteFilesForRecordsOfType(committed() ? Type.REMOVE : Type.ADD);
 
             // we sync the parent directories between contents and log deletion

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9ccccf28/src/java/org/apache/cassandra/db/lifecycle/LogTransaction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/lifecycle/LogTransaction.java b/src/java/org/apache/cassandra/db/lifecycle/LogTransaction.java
index f99f432..27c7955 100644
--- a/src/java/org/apache/cassandra/db/lifecycle/LogTransaction.java
+++ b/src/java/org/apache/cassandra/db/lifecycle/LogTransaction.java
@@ -17,8 +17,10 @@
  */
 package org.apache.cassandra.db.lifecycle;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.NoSuchFileException;
 import java.util.*;
@@ -202,7 +204,15 @@ class LogTransaction extends Transactional.AbstractTransactional implements
Tran
         }
         catch (NoSuchFileException e)
         {
-            logger.error("Unable to delete {} as it does not exist", file);
+            logger.error("Unable to delete {} as it does not exist, see debug log file for
stack trace", file);
+            if (logger.isDebugEnabled())
+            {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                PrintStream ps = new PrintStream(baos);
+                e.printStackTrace(ps);
+                ps.close();
+                logger.debug("Unable to delete {} as it does not exist, stack trace:\n {}",
file, baos.toString());
+            }
         }
         catch (IOException e)
         {
@@ -313,7 +323,11 @@ class LogTransaction extends Transactional.AbstractTransactional implements
Tran
                 // If we can't successfully delete the DATA component, set the task to be
retried later: see TransactionTidier
                 File datafile = new File(desc.filenameFor(Component.DATA));
 
-                delete(datafile);
+                if (datafile.exists())
+                    delete(datafile);
+                else if (!wasNew)
+                    logger.error("SSTableTidier ran with no existing data file for an sstable
that was not new");
+
                 // let the remainder be cleaned up by delete
                 SSTable.delete(desc, SSTable.discoverComponentsFor(desc));
             }


Mime
View raw message