db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suresh Thalamati <tsur...@Source-Zone.org>
Subject Re: java1.4.2 "rws" mode fix: LogToFile.java diff
Date Thu, 02 Sep 2004 00:28:11 GMT
Joseph Grace wrote:

> Dear derby-dev:
>
> Apologies for any faux-pas.  I'm not sure what diff to use, so I used 
> diff -c2 to make the following patch.
>
> I made this change to get derby running under java 1.4.2 on Mac OSX 
> 10.3.5 (i.e., the latest and greatest version).  I believe the patch 
> fixes a bug where the database gets created twice unnecessarily.  This 
> bug was causing the simple instructions example ("connect 
> 'jdbc:derby:test;create=true';") to choke with a file already exists 
> error.  Apparently, this situation crops up whenever "rws" mode was 
> available, and would not occur prior to 1.4.1 (since apparently "rws" 
> was too buggy to use until 1.4.2 and, so, was avoided).  Anyway, 
> here's what I believe is a fix for that issue and, at least, got the 
> database to initialize per instructions on my system.
>
Hi Joe ,

   I am trying to understand the problem you described above.  What is 
the error you are seeing when you try to create 
   the database  in the  Mac environment. Are u seeing this problem  
with JDK1.4.2 on  any other OS ?
   Could  you please explain  more on  how  database can be  created 
twice ? 
    From the changes described  here, what I find  is  you are trying to 
avoid  open/create
    of  log file in "rw" mode first and  then  in  "rws" mode  by making 
  it  a single  privRandomAccess File call:

  >> StorageRandomAccessFile theLog = privRandomAccessFile( logFile, 
isWriteSynced? "rws": "rw");

 
  

>
>
> *** LogToFile.java.org  Thu Aug 26 12:07:32 2004
> --- LogToFile.java      Tue Aug 31 22:19:16 2004
> ***************
> *** 889,902 ****
>                                                 lastFlush   = 
> endPosition;
>
>

   I think  the following part of the  changes might increase database 
creation time when write sync is enabled..
   Please correct me if  my observation is  not right . I think  the 
Reason behind opening files in "RW" mode first 
   and then reopen in "RWS"  might have been  to make preallocation of 
the log file  finish  faster.
.  Preallocation of  the log file  by doing writes  to a file opened in 
"rws"  mode   will be much  slower than 
   doing writes to file opened in "rw" mode  .


> ***************
> *** 3004,3008 ****
>
>                                         // don't need to try to delete 
> it, we know it isn't there
> !                     StorageRandomAccessFile theLog = 
> privRandomAccessFile(logFile, "rw");
>
>                                         if (!initLogFile(theLog, 
> logFileNumber, LogCounter.INVALID_LOG_INSTANT))
> --- 3004,3008 ----
>
>                                         // don't need to try to delete 
> it, we know it isn't there
> !                     StorageRandomAccessFile theLog = 
> privRandomAccessFile( logFile, isWriteSynced? "rws": "rw");
>
>                                         if (!initLogFile(theLog, 
> logFileNumber, LogCounter.INVALID_LOG_INSTANT))
> ***************
> *** 3015,3028 ****
>                                         lastFlush = 
> theLog.getFilePointer();
>
> !                     //if write sync is true , prellocate the log file
> !                     //and reopen the file in rws mode.
> !                     if(isWriteSynced)
>                       {
> !                         //extend the file by wring zeros to it
> !                         preAllocateNewLogFile(theLog);
> !                         theLog.close();
> !                         theLog=  privRandomAccessFile(logFile, "rws");
> !                         //postion the log at the current log end 
> postion
> !                         theLog.seek(endPosition);
>                       }
>                                         logOut = new 
> LogAccessFile(theLog, logBufferSize);
> --- 3015,3026 ----
>                                         lastFlush = 
> theLog.getFilePointer();
>
> !                     //  if write sync is true , preallocate the log 
> file
> !                     //  and reposition cursor.
> !                     if( isWriteSynced)
>                       {
> !                         //  extend the file by writing zeros to it
> !                         preAllocateNewLogFile( theLog);
> !                         //  position the log at the current log end 
> position
> !                         theLog.seek( endPosition);
>                       }
>                                         logOut = new 
> LogAccessFile(theLog, logBufferSize);
>


Thanks
-suresh


Mime
View raw message