db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1236418 - /db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/io/DirFile.java
Date Thu, 26 Jan 2012 22:28:15 GMT
Author: mikem
Date: Thu Jan 26 22:28:14 2012
New Revision: 1236418

URL: http://svn.apache.org/viewvc?rev=1236418&view=rev
Log:
DERBY-5574 encryption test in encryption nightly suite test fails with ERROR XBM0S: Unable
to rename file error

merged svn #1236370 trunk to 10.8 branch.

Catch errors on rename, and retry hoping that error is caused by some
temporary file system resource issue.  Similar methodology that other
parts of the system uses on read and write errors.  Worst case system
retries 5 times and still throws the error, best case a subsequent retry
succeeds and user application is never aware an error was encountered.


Modified:
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/io/DirFile.java

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/io/DirFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/io/DirFile.java?rev=1236418&r1=1236417&r2=1236418&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/io/DirFile.java (original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/io/DirFile.java Thu Jan
26 22:28:14 2012
@@ -26,6 +26,8 @@ import org.apache.derby.io.StorageRandom
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
+import org.apache.derby.iapi.util.InterruptStatus;
+
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -225,12 +227,16 @@ class DirFile extends File implements St
     } // end of getRandomAccessFile
 
     /**
-     * Rename the file denoted by this name. Note that StorageFile objects are immutable.
This method
-     * renames the underlying file, it does not change this StorageFile object. The StorageFile
object denotes the
-     * same name as before, however the exists() method will return false after the renameTo
method
-     * executes successfully.
+     * Rename the file denoted by this name. 
      *
-     *<p>It is not specified whether this method will succeed if a file already exists
under the new name.
+     * Note that StorageFile objects are immutable. This method renames the 
+     * underlying file, it does not change this StorageFile object. The 
+     * StorageFile object denotes the same name as before, however the exists()
+     * method will return false after the renameTo method executes successfully.
+     *
+     * <p>
+     * It is not specified whether this method will succeed if a file 
+     * already exists under the new name.
      *
      * @param newName the new name.
      *
@@ -238,7 +244,30 @@ class DirFile extends File implements St
      */
     public boolean renameTo( StorageFile newName)
     {
-        return super.renameTo( (File) newName);
+        boolean rename_status = super.renameTo( (File) newName);
+        int     retry_count   = 1;
+
+        while (!rename_status && (retry_count <= 5))
+        {
+            // retry operation, hoping a temporary I/O resource issue is 
+            // causing the failure.
+
+            try
+            {
+                Thread.sleep(1000 * retry_count);
+            }
+            catch (InterruptedException ie)
+            {
+                // This thread received an interrupt as well, make a note.
+                InterruptStatus.setInterrupted();
+            }
+
+            rename_status = super.renameTo((File) newName);
+
+            retry_count++;
+        }
+
+        return(rename_status);
     }
 
     /**



Mime
View raw message