Repository: asterixdb Updated Branches: refs/heads/master 6cd3127c4 -> 8026b2dc9
[NO ISSUE][STO] Skip flush recovery of empty resources - user model changes: no - storage format changes: no - interface changes: no Details: - Before this change, recovery would throw a NullPointerException on recovery of a flush operation on a component without update logs. - Since this can happen, we simply check for the case and skip the flush. Change-Id: Ib01d7513f43830109632760860d34ca3dcddeaee Reviewed-on: https://asterix-gerrit.ics.uci.edu/2844 Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Reviewed-by: abdullah alamoudi <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/8026b2dc Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/8026b2dc Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/8026b2dc Branch: refs/heads/master Commit: 8026b2dc95b0b48949b192409be97ec40ac3fa2d Parents: 6cd3127 Author: Abdullah Alamoudi <[email protected]> Authored: Fri Aug 3 15:46:20 2018 -0700 Committer: abdullah alamoudi <[email protected]> Committed: Fri Aug 3 23:33:48 2018 -0700 ---------------------------------------------------------------------- .../apache/asterix/app/nc/RecoveryManager.java | 30 ++++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8026b2dc/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java index 5e8a5e8..adf9960 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java @@ -296,7 +296,7 @@ public class RecoveryManager implements IRecoveryManager, ILifeCycleComponent { ((INcApplicationContext) (serviceCtx.getApplicationContext())).getIndexCheckpointManagerProvider(); Map<Long, LocalResource> resourcesMap = localResourceRepository.loadAndGetAllResources(); - Map<Long, Long> resourceId2MaxLSNMap = new HashMap<>(); + final Map<Long, Long> resourceId2MaxLSNMap = new HashMap<>(); TxnEntityId tempKeyTxnEntityId = new TxnEntityId(-1, -1, -1, null, -1, false); ILogRecord logRecord = null; @@ -399,19 +399,25 @@ public class RecoveryManager implements IRecoveryManager, ILifeCycleComponent { // we only need to flush open indexes here (opened by previous update records) // if an index has no ongoing updates, then it's memory component must be empty // and there is nothing to flush - for (IndexInfo iInfo : dsInfo.getIndexes().values()) { + for (final IndexInfo iInfo : dsInfo.getIndexes().values()) { if (iInfo.isOpen() && iInfo.getPartition() == partition) { - maxDiskLastLsn = resourceId2MaxLSNMap.get(iInfo.getResourceId()); - index = iInfo.getIndex(); - if (logRecord.getLSN() > maxDiskLastLsn - && !index.isCurrentMutableComponentEmpty()) { - // schedule flush - redoFlush(index, logRecord); - redoCount++; + Long maxLsnBeforeFlush = resourceId2MaxLSNMap.get(iInfo.getResourceId()); + if (maxLsnBeforeFlush != null) { + // If there was at least one update to the resource. + // IMPORTANT: Don't remove the check above + // This check is to support indexes without transaction logs + maxDiskLastLsn = maxLsnBeforeFlush; + index = iInfo.getIndex(); + if (logRecord.getLSN() > maxDiskLastLsn + && !index.isCurrentMutableComponentEmpty()) { + // schedule flush + redoFlush(index, logRecord); + redoCount++; + } else { + // TODO: update checkpoint file? + } } else { - // otherwise, do nothing since this component had no records when flush was - // scheduled.. TODO: update checkpoint file? and do the - // lsn checks from the checkpoint file + // TODO: update checkpoint file? } } }
