Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 7775 invoked from network); 6 Oct 2005 23:48:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Oct 2005 23:48:55 -0000 Received: (qmail 47001 invoked by uid 500); 6 Oct 2005 23:48:55 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 46942 invoked by uid 500); 6 Oct 2005 23:48:54 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 46931 invoked by uid 99); 6 Oct 2005 23:48:54 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 06 Oct 2005 16:48:54 -0700 Received: (qmail 7534 invoked by uid 65534); 6 Oct 2005 23:47:37 -0000 Message-ID: <20051006234737.7533.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r306963 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Date: Thu, 06 Oct 2005 23:47:36 -0000 To: derby-commits@db.apache.org From: mikem@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: mikem Date: Thu Oct 6 16:47:31 2005 New Revision: 306963 URL: http://svn.apache.org/viewcvs?rev=306963&view=rev Log: committing on behalf of: Suresh Thalamati was hoping this issue will go away , but it seems to have appeared again in jdk1.5. Although there is a workaround by setting derby.storage.fileSyncTransactionLog=true. I think for users who are just tryingout Derby , hitting this problem is very annoying. Resubmmitting the workaround patch(derby1.diff) for this problem againest main trunk. This patch solves the problem by Catching the FileNotFoundException then set log write mode to file Sync and then open the log files in plain "rw" mode. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java?rev=306963&r1=306962&r2=306963&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java Thu Oct 6 16:47:31 2005 @@ -92,6 +92,7 @@ import java.io.DataOutputStream; import java.io.ByteArrayInputStream; import java.io.DataInputStream; +import java.io.FileNotFoundException; import java.net.MalformedURLException; import java.net.URL; @@ -903,7 +904,7 @@ //extend the file by wring zeros to it preAllocateNewLogFile(theLog); theLog.close(); - theLog= privRandomAccessFile(logFile, "rws"); + theLog = openLogFileInWriteMode(logFile); //postion the log at the current end postion theLog.seek(endPosition); } @@ -939,7 +940,7 @@ try { if(isWriteSynced) - theLog = privRandomAccessFile(logFile, "rws"); + theLog = openLogFileInWriteMode(logFile); else theLog = privRandomAccessFile(logFile, "rw"); } @@ -1914,7 +1915,7 @@ //extend the file by wring zeros to it preAllocateNewLogFile(newLog); newLog.close(); - newLog= privRandomAccessFile(newLogFile, "rws"); + newLog = openLogFileInWriteMode(newLogFile); newLog.seek(endPosition); } @@ -3029,7 +3030,7 @@ //extend the file by wring zeros to it preAllocateNewLogFile(firstLog); firstLog.close(); - firstLog= privRandomAccessFile(logFile, "rws"); + firstLog = openLogFileInWriteMode(logFile); //postion the log at the current log end postion firstLog.seek(endPosition); } @@ -4643,15 +4644,32 @@ } } // end of preAllocateNewLogFile - /*open the given log file name for writes; if write sync - *is enabled open in rws mode otherwise in rw mode. - */ - public StorageRandomAccessFile openLogFileInWriteMode(StorageFile logFile) throws IOException + + /** + * open the given log file name for writes; if file can not be + * be opened in write sync mode then disable the write sync mode and + * open the file in "rw" mode. + */ + private StorageRandomAccessFile openLogFileInWriteMode(StorageFile logFile) throws IOException { - if(isWriteSynced) - return privRandomAccessFile(logFile, "rws"); - else - return privRandomAccessFile(logFile, "rw"); + StorageRandomAccessFile log; + try{ + log = privRandomAccessFile(logFile, "rws"); + }catch(FileNotFoundException ex) + { + // Normally this exception should never occur. For some reason + // currently on Mac JVM 1.4.2 FileNotFoundException exception is + // thrown if a file is opened in "rws" mode and if it already + // exists. Please refere to Derby-1 for more/ details on this issue. + // Temporary workaround to avoid this problem is to make the logging + // system use file sync mechanism. + + // disable the write sync and open the file in "rw" mode. + isWriteSynced = false; + log = privRandomAccessFile(logFile, "rw"); + } + + return log ; }