added the sharp checkpoint functionality in the RecoveryManager. We need to change CC layer to trigger the sharp checkpoint and stop the incomming queries during the checkpoint
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1269 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCBootstrapImpl.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCBootstrapImpl.java
index 51b61d7..dfd7065 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCBootstrapImpl.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCBootstrapImpl.java
@@ -75,7 +75,7 @@
recoveryMgr.startRecovery(true);
}
}
- recoveryMgr.checkpoint(false);
+ recoveryMgr.checkpoint(true);
if (isMetadataNode) {
//#. clean-up incomplete DDL operations, which is DDLRecovery
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
index 00f8204..b4257d5 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogManager.java
@@ -211,13 +211,8 @@
/*
* place the log anchor at the end of the last log record written.
*/
- PhysicalLogLocator nextPhysicalLsn = LogUtil.initializeLogAnchor(this);
- startingLsn = nextPhysicalLsn.getLsn();
- lastFlushedLsn.set(startingLsn - 1);
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info(" Starting lsn is : " + startingLsn);
- }
- lsn.set(startingLsn);
+ PhysicalLogLocator nextPhysicalLsn = initLSN();
+
/*
* initialize meta data for each log page.
*/
@@ -651,6 +646,28 @@
readDiskLog(lsnValue, logicalLogLocator);
}
+ public void renewLogFiles() throws ACIDException {
+ List<String> logFileNames = LogUtil.getLogFiles(logManagerProperties);
+ for (String name : logFileNames) {
+ File file = new File(LogUtil.getLogFilePath(logManagerProperties, Long.parseLong(name)));
+ if (!file.delete()) {
+ throw new ACIDException("Failed to delete a file: " + name);
+ }
+ }
+ initLSN();
+ }
+
+ private PhysicalLogLocator initLSN() throws ACIDException {
+ PhysicalLogLocator nextPhysicalLsn = LogUtil.initializeLogAnchor(this);
+ startingLsn = nextPhysicalLsn.getLsn();
+ lastFlushedLsn.set(startingLsn - 1);
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info(" Starting lsn is : " + startingLsn);
+ }
+ lsn.set(startingLsn);
+ return nextPhysicalLsn;
+ }
+
@Override
public ILogRecordHelper getLogRecordHelper() {
return logRecordHelper;
@@ -899,7 +916,7 @@
throw new Error(" exception in flushing log page", ioe);
} catch (InterruptedException e) {
e.printStackTrace();
- break;
+ break;
}
}
}
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
index a894f9e..fb37202 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -422,9 +422,6 @@
}
}
}
-
- //TODO
- //think about discarding all existing logs.
//#. create and store the checkpointObject into the new checkpoint file
long minMCTFirstLSN = Long.MAX_VALUE;
@@ -474,6 +471,10 @@
file.delete();
}
}
+
+ if (isSharpCheckpoint) {
+ logMgr.renewLogFiles();
+ }
}
private CheckpointObject readCheckpoint() throws ACIDException, FileNotFoundException {