Skip to content
Permalink
Browse files
[NO ISSUE][TX] Stop reading logs when an empty file is encountered
- user model changes: no
- storage format changes: no
- interface changes: no

Details:

- Whenever an empty txn log file is encountered, do not
  attempt to read the next log file since an empty log
  file indicates that no more logs exist.
- Add test case.

Change-Id: I8d95c9e444dcdea21c4af35779d4c0c38f6577e5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/9883
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Ian Maxon <imaxon@uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
  • Loading branch information
mhubail committed Feb 7, 2021
1 parent 9f454cd commit 1f238097fb756556628f2027f47acd4390ace36f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
@@ -201,7 +201,7 @@ private static ITransactionContext beingTransaction(INcApplicationContext ncAppC
return txnCtx;
}

private static void prepareNextLogFile(LogManager logManager) throws Exception {
public static void prepareNextLogFile(LogManager logManager) throws Exception {
Method ensureLastPageFlushed;
Method prepareNextLogFile;
String targetMethod = null;
@@ -22,8 +22,10 @@

import org.apache.asterix.api.common.AsterixHyracksIntegrationUtil;
import org.apache.asterix.common.TestDataUtil;
import org.apache.asterix.common.api.INcApplicationContext;
import org.apache.asterix.common.config.StorageProperties;
import org.apache.asterix.metadata.bootstrap.MetadataBuiltinEntities;
import org.apache.asterix.transaction.management.service.logging.LogManager;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -104,4 +106,20 @@ public void reoveryAfterRebalance() throws Exception {
final long countAfterRecovery = TestDataUtil.getDatasetCount(datasetName);
Assert.assertEquals(countBeforeRecovery, countAfterRecovery);
}

@Test
public void recoveryWithEmptyLogFile() throws Exception {
String datasetName = "ds";
TestDataUtil.createIdOnlyDataset(datasetName);
TestDataUtil.upsertData(datasetName, 10);
final INcApplicationContext ncAppCtx = (INcApplicationContext) integrationUtil.ncs[0].getApplicationContext();
final LogManager logManager = (LogManager) ncAppCtx.getTransactionSubsystem().getLogManager();
// do ungraceful shutdown to enforce recovery
integrationUtil.deinit(false);
// create empty txn log file
LogManagerTest.prepareNextLogFile(logManager);
// ensure recovery completes
integrationUtil.init(false, TEST_CONFIG_FILE_PATH);
TestDataUtil.upsertData(datasetName, 10);
}
}
@@ -163,7 +163,7 @@ private ReturnState waitForFlushOrReturnIfEOF() {
*/
private boolean refillLogReadBuffer() {
try {
if (readLSN % logFileSize == logFile.size()) {
if (logFile.size() > 0 && readLSN % logFileSize == logFile.size()) {
readLSN += logFileSize - (readLSN % logFileSize);
getLogFile();
}

0 comments on commit 1f23809

Please sign in to comment.