You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by mi...@apache.org on 2006/04/18 18:27:44 UTC
svn commit: r394981 -
/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java
Author: mikem
Date: Tue Apr 18 09:27:39 2006
New Revision: 394981
URL: http://svn.apache.org/viewcvs?rev=394981&view=rev
Log:
DERBY-1113, committing on behalf of Suresh Thalamati
The reason for missing log files is truncation logic at checkpoint was
incorrectly deleting the log files that were needed for crash recovery
if the backup is progress at the same time; The first log file that should
not be deleted was incorrectly assigned to the log file number that is yet
to be written to the backup.
Attached patch changes the logic, so that all the log files that are required for both crash recovery and the backup are not deleted. Basically the first log file that should not be deleted is the lowest of first log needed for crash recovery or the log file that is yet to be copied to the backup.
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=394981&r1=394980&r2=394981&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 Tue Apr 18 09:27:39 2006
@@ -462,7 +462,7 @@
// log file that is yet to be copied to backup, updates to this variable
// needs to visible checkpoint thread.
- private volatile long firstLogFileToBackup ;
+ private volatile long logFileToBackup ;
// It is set to true when online backup is in progress, updates to
// this variable needs to visible to checkpoint thread.
private volatile boolean backupInProgress = false;
@@ -2064,10 +2064,20 @@
if ((firstLogNeeded = getFirstLogNeeded(checkpoint))==-1)
return;
- // when backup is in progress, Any that are yet to be copied to the
- // backup should not be deleted, even if they are
- // not required for crash recovery.
- firstLogNeeded = (backupInProgress ? firstLogFileToBackup : firstLogNeeded);
+ // when backup is in progress, log files that are yet to
+ // be copied to the backup should not be deleted, even
+ // if they are not required for crash recovery.
+ if(backupInProgress) {
+ long logFileNeededForBackup = logFileToBackup;
+ // check if the log file number is yet to be copied
+ // to the backup is less than the log file required
+ // for crash recovery, if it is then make the first
+ // log file that should not be deleted is the log file
+ // that is yet to be copied to the backup.
+ if (logFileNeededForBackup < firstLogNeeded)
+ firstLogNeeded = logFileNeededForBackup;
+ }
+
oldFirstLog = firstLogFileNumber;
firstLogFileNumber = firstLogNeeded;
@@ -3205,15 +3215,23 @@
StorageFile logDir;
//find the first log file number that is useful
long firstLogNeeded = getFirstLogNeeded(currentCheckpoint);
-
-
- // when backup is in progress, Any that are yet to be copied to the
- // backup should not be deleted, even if they are
- // not required for crash recovery.
- firstLogNeeded = (backupInProgress ? firstLogFileToBackup : firstLogNeeded);
-
if (firstLogNeeded == -1)
return;
+
+ // when backup is in progress, log files that are yet to
+ // be copied to the backup should not be deleted, even
+ // if they are not required for crash recovery.
+ if(backupInProgress) {
+ long logFileNeededForBackup = logFileToBackup;
+ // check if the log file number is yet to be copied
+ // to the backup is less than the log file required
+ // for crash recovery, if it is then make the first
+ // log file that should not be deleted is the log file
+ // that is yet to be copied to the backup.
+ if (logFileNeededForBackup < firstLogNeeded)
+ firstLogNeeded = logFileNeededForBackup;
+ }
+
try{
logDir = getLogDirectory();
}catch (StandardException se)
@@ -4481,7 +4499,7 @@
}
// find the first log file number that is active
- firstLogFileToBackup = getFirstLogNeeded(currentCheckpoint);
+ logFileToBackup = getFirstLogNeeded(currentCheckpoint);
}
// copy all the log files that has to go into the backup
@@ -4497,16 +4515,16 @@
throws StandardException
{
- while(firstLogFileToBackup <= lastLogFileToBackup)
+ while(logFileToBackup <= lastLogFileToBackup)
{
- StorageFile fromFile = getLogFileName(firstLogFileToBackup);
+ StorageFile fromFile = getLogFileName(logFileToBackup);
File toFile = new File(toDir, fromFile.getName());
if(!privCopyFile(fromFile, toFile))
{
throw StandardException.newException(SQLState.RAWSTORE_ERROR_COPYING_FILE,
fromFile, toFile);
}
- firstLogFileToBackup++;
+ logFileToBackup++;
}
}