fixed issue 290: made log cursor read from 0 offset of each log page in the log file, meaning do not allow to read from the middle of the page.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@1455 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
index 9ad66bc..8a2b188 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogCursor.java
@@ -95,13 +95,16 @@
//if the readOnlyBuffer should be reloaded, then load the log page from the log file.
//needReloadBuffer is set to true if the log record is read from the memory log page.
if (needReloadBuffer) {
- readOnlyBuffer = getReadOnlyBuffer(logicalLogLocator.getLsn(), logManager.getLogManagerProperties()
- .getLogBufferSize());
+ //log page size doesn't exceed integer boundary
+ int offset = (int)(logicalLogLocator.getLsn() % logManager.getLogManagerProperties().getLogPageSize());
+ long adjustedLSN = logicalLogLocator.getLsn() - offset;
+ readOnlyBuffer = getReadOnlyBuffer(adjustedLSN, logManager.getLogManagerProperties()
+ .getLogPageSize());
logicalLogLocator.setBuffer(readOnlyBuffer);
- logicalLogLocator.setMemoryOffset(0);
+ logicalLogLocator.setMemoryOffset(offset);
needReloadBuffer = false;
}
-
+
//check whether the currentOffset has enough space to have new log record by comparing
//the smallest log record type(which is commit)'s log header.
while (logicalLogLocator.getMemoryOffset() <= readOnlyBuffer.getSize()
@@ -133,7 +136,7 @@
long lsnpos = ((logicalLogLocator.getLsn() / logManager.getLogManagerProperties().getLogPageSize()) + 1)
* logManager.getLogManagerProperties().getLogPageSize();
- readOnlyBuffer = getReadOnlyBuffer(lsnpos, logManager.getLogManagerProperties().getLogBufferSize());
+ readOnlyBuffer = getReadOnlyBuffer(lsnpos, logManager.getLogManagerProperties().getLogPageSize());
if (readOnlyBuffer != null) {
logicalLogLocator.setBuffer(readOnlyBuffer);
logicalLogLocator.setLsn(lsnpos);
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 c73f693..c27ae20 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
@@ -657,7 +657,9 @@
}
if (!valid) {
if (currentLogLocator.getLsn() != lastLSNLogLocator.getLsn()) {
- throw new ACIDException("Log File Corruption: lastLSN mismatch");
+ throw new ACIDException("LastLSN mismatch: " + lastLSNLogLocator.getLsn() + " vs "
+ + currentLogLocator.getLsn() + " during Rollback a transaction( " + txnContext.getJobId()
+ + ")");
} else {
break;//End of Log File
}