This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 2099f8009596796a9b067480129d9dddf4860ed5 Author: Murtadha Hubail <[email protected]> AuthorDate: Tue Feb 15 02:54:13 2022 +0300 [NO ISSUE][OTH] Ensure no failures during transaction completion - user model changes: no - storage format changes: no - interface changes: no Details: - When completing a transaction, only untouch an index if it was successfully touched at the beginning of the transaction. - Log when an expected index is not found and throw an exception to avoid an NPE. Change-Id: Ie0d4879630ae302485d595060dd87a896d151307 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/15288 Integration-Tests: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> Tested-by: Murtadha Hubail <[email protected]> Tested-by: Jenkins <[email protected]> --- .../asterix/common/context/BaseOperationTracker.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java index f8a81e4..5964bb4 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/BaseOperationTracker.java @@ -25,9 +25,12 @@ import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex; import org.apache.hyracks.storage.am.lsm.common.api.LSMOperationType; import org.apache.hyracks.storage.common.IModificationOperationCallback; import org.apache.hyracks.storage.common.ISearchOperationCallback; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public class BaseOperationTracker implements ITransactionOperationTracker { + private static final Logger LOGGER = LogManager.getLogger(); protected final int datasetID; protected final DatasetInfo dsInfo; @@ -67,13 +70,23 @@ public class BaseOperationTracker implements ITransactionOperationTracker { * from being evicted/dropped until the transaction completes */ dsInfo.touch(); - dsInfo.getIndexes().get(resourceId).touch(); + IndexInfo indexInfo = dsInfo.getIndexes().get(resourceId); + if (indexInfo == null) { + LOGGER.error("could not find resource id {} in dataset {}; registered indexes {}", resourceId, dsInfo, + dsInfo.getIndexes()); + throw new IllegalStateException("could not find resource id " + resourceId + " in dataset " + dsInfo); + } + indexInfo.touch(); } @Override public void afterTransaction(long resourceId) { dsInfo.untouch(); - dsInfo.getIndexes().get(resourceId).untouch(); + IndexInfo indexInfo = dsInfo.getIndexes().get(resourceId); + if (indexInfo != null) { + // only untouch if the touch in beforeTransaction succeeded + indexInfo.untouch(); + } } public DatasetInfo getDatasetInfo() {
