Skip to content
Permalink
Browse files
[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 <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Tested-by: Murtadha Hubail <mhubail@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
  • Loading branch information
mhubail committed Feb 15, 2022
1 parent a6c858b commit 2099f8009596796a9b067480129d9dddf4860ed5
Showing 1 changed file with 15 additions and 2 deletions.
@@ -25,9 +25,12 @@
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 void beforeTransaction(long resourceId) {
* 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() {

0 comments on commit 2099f80

Please sign in to comment.