You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2021/12/01 17:31:12 UTC

[cassandra] branch trunk updated: Tolerate local files in data dir during startup

This is an automated email from the ASF dual-hosted git repository.

jmckenzie pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 92dc415  Tolerate local files in data dir during startup
92dc415 is described below

commit 92dc415902654c0e69de47205af62b9bb4532809
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Thu Oct 28 15:35:57 2021 -0400

    Tolerate local files in data dir during startup
    
    Patch by Alex Petrov; reviewed by Aleksey Yeschenko, Jon Meredith, and Caleb Rackliffe for CASSANDRA-17082
    
    Co-authored-by: Alex Petrov <ol...@gmail.com>
    Co-authored-by: Josh McKenzie <jm...@apache.org>
---
 CHANGES.txt                                               |  1 +
 .../org/apache/cassandra/io/sstable/SSTableHeaderFix.java | 12 +++++++++++-
 .../apache/cassandra/io/sstable/SSTableHeaderFixTest.java | 15 +++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index c399c0d..5203504 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.1
+ * Make nodes more resilient to local unrelated files during startup (CASSANDRA-17082)
  * repair prepare message would produce a wrong error message if network timeout happened rather than reply wait timeout (CASSANDRA-16992)
  * Log queries that fail on timeout or unavailable errors up to once per minute by default (CASSANDRA-17159)
  * Refactor normal/preview/IR repair to standardize repair cleanup and error handling of failed RepairJobs (CASSANDRA-17069)
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableHeaderFix.java b/src/java/org/apache/cassandra/io/sstable/SSTableHeaderFix.java
index ad0a722..643a9de 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableHeaderFix.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableHeaderFix.java
@@ -298,7 +298,17 @@ public abstract class SSTableHeaderFix
     {
         Stream.of(path)
               .flatMap(SSTableHeaderFix::maybeExpandDirectory)
-              .filter(p -> Descriptor.fromFilenameWithComponent(new File(p)).right.type == Component.Type.DATA)
+              .filter(p -> {
+                  try
+                  {
+                      return Descriptor.fromFilenameWithComponent(new File(p.toFile())).right.type == Component.Type.DATA;
+                  }
+                  catch (IllegalArgumentException t)
+                  {
+                      logger.info("Couldn't parse filename {}, ignoring", p);
+                      return false;
+                  }
+              })
               .map(Path::toString)
               .map(Descriptor::fromFilename)
               .forEach(descriptors::add);
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableHeaderFixTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableHeaderFixTest.java
index f578f77..5b28c0e 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableHeaderFixTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableHeaderFixTest.java
@@ -33,6 +33,7 @@ import java.util.stream.IntStream;
 import com.google.common.collect.Sets;
 import org.apache.cassandra.io.util.File;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -735,6 +736,20 @@ public class SSTableHeaderFixTest
         }
     }
 
+    @Test
+    public void ignoresStaleFilesTest() throws Exception
+    {
+        File dir = temporaryFolder;
+        IntStream.range(1, 2).forEach(g -> generateFakeSSTable(dir, g));
+
+        File newFile = new File(dir.toAbsolute(), "something_something-something.something");
+        Assert.assertTrue(newFile.createFileIfNotExists());
+
+        SSTableHeaderFix headerFix = builder().withPath(dir.toPath())
+                                              .build();
+        headerFix.execute();
+    }
+
     private static final Pattern p = Pattern.compile(".* Column '([^']+)' needs to be updated from type .*");
 
     private SSTableHeaderFix.Builder builder()

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org