krummas commented on a change in pull request #875:
URL: https://github.com/apache/cassandra/pull/875#discussion_r580868025



##########
File path: src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
##########
@@ -2276,8 +2276,24 @@ public static SSTableReader 
moveAndOpenSSTable(ColumnFamilyStore cfs, Descriptor
             throw new RuntimeException(msg);
         }
 
-        logger.info("Renaming new SSTable {} to {}", oldDescriptor, 
newDescriptor);
-        SSTableWriter.rename(oldDescriptor, newDescriptor, components);
+        if (copyData)
+        {
+            try
+            {
+                logger.info("Hardlinking new SSTable {} to {}", oldDescriptor, 
newDescriptor);
+                SSTableWriter.hardlink(oldDescriptor, newDescriptor, 
components);
+            }
+            catch (Throwable t)

Review comment:
       we should not catch throwable here without rethrowing - we might hide 
OOM errors for example
   

##########
File path: src/java/org/apache/cassandra/io/util/FileUtils.java
##########
@@ -193,6 +171,58 @@ public static File createDeletableTempFile(String prefix, 
String suffix)
         return f;
     }
 
+    public static void createHardLink(String from, String to)
+    {
+        createHardLink(new File(from), new File(to));
+    }
+
+    public static void createHardLink(File from, File to)
+    {
+        if (to.exists())
+            throw new RuntimeException("Tried to create duplicate hard link to 
" + to);
+        if (!from.exists())
+            throw new RuntimeException("Tried to hard link to file that does 
not exist " + from);
+
+        try
+        {
+            Files.createLink(to.toPath(), from.toPath());
+        }
+        catch (IOException e)
+        {
+            throw new FSWriteError(e, to);
+        }
+    }
+
+    public static void createHardLinkWithConfirm(File from, File to)
+    {
+        try
+        {
+            createHardLink(from, to);
+        }
+        catch (Throwable t)
+        {
+            throw new RuntimeException(String.format("Unable to hardlink from 
%s to %s", from, to), t);
+        }
+    }
+
+    public static void createHardLinkWithConfirm(String from, String to)
+    {
+        createHardLinkWithConfirm(new File(from), new File(to));
+    }
+
+    public static void createHardLinkWithoutConfirm(String from, String to)
+    {
+        try
+        {
+            createHardLink(new File(from), new File(to));
+        }
+        catch (Throwable t)

Review comment:
       same as above - don't catch throwable




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to