Repository: asterixdb Updated Branches: refs/heads/master 83cc06e0b -> 297a31f81
[ASTERIXDB-2308][STO] Prevent Race To Allocate Memory Components - user model changes: no - storage format changes: no - interface changes: no Details: - Ensure concurrent threads will not attempt to allocate memory components twice. - Synchronize index lifecycle operations. - Remove unused methods. Change-Id: Ibd424ba6a2a68939f6ab8a4338c2f6c0c8057ed1 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2489 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Ian Maxon <ima...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/297a31f8 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/297a31f8 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/297a31f8 Branch: refs/heads/master Commit: 297a31f81658b7f774a59d25e061de2d0f2c215f Parents: 83cc06e Author: Murtadha Hubail <mhub...@apache.org> Authored: Fri Mar 16 00:51:31 2018 +0300 Committer: Murtadha Hubail <mhub...@apache.org> Committed: Fri Mar 16 00:32:04 2018 -0700 ---------------------------------------------------------------------- .../am/lsm/common/impls/AbstractLSMIndex.java | 21 ++++---------------- 1 file changed, 4 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/297a31f8/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java index af8c702..2db2f79 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java @@ -41,7 +41,6 @@ import org.apache.hyracks.storage.am.common.impls.NoOpIndexAccessParameters; import org.apache.hyracks.storage.am.common.ophelpers.IndexOperation; import org.apache.hyracks.storage.am.lsm.common.api.IComponentFilterHelper; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent; -import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponent.ComponentState; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentFilterFrameFactory; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentId; import org.apache.hyracks.storage.am.lsm.common.api.ILSMComponentId.IdCompareResult; @@ -97,7 +96,7 @@ public abstract class AbstractLSMIndex implements ILSMIndex { protected final boolean durable; protected boolean isActive; protected final AtomicBoolean[] flushRequests; - protected boolean memoryComponentsAllocated = false; + protected volatile boolean memoryComponentsAllocated = false; protected ITracer tracer; // Factory for creating on-disk index components during flush and merge. protected final ILSMDiskComponentFactory componentFactory; @@ -219,7 +218,7 @@ public abstract class AbstractLSMIndex implements ILSMIndex { isActive = false; } - protected void flushMemoryComponent() throws HyracksDataException { + private void flushMemoryComponent() throws HyracksDataException { BlockingIOOperationCallbackWrapper cb = new BlockingIOOperationCallbackWrapper(ioOpCallback); ILSMIndexAccessor accessor = createAccessor(NoOpIndexAccessParameters.INSTANCE); accessor.scheduleFlush(cb); @@ -247,7 +246,7 @@ public abstract class AbstractLSMIndex implements ILSMIndex { } @Override - public void destroy() throws HyracksDataException { + public synchronized void destroy() throws HyracksDataException { if (isActive) { throw HyracksDataException.create(ErrorCode.CANNOT_DESTROY_ACTIVE_INDEX); } @@ -262,7 +261,7 @@ public abstract class AbstractLSMIndex implements ILSMIndex { } @Override - public void clear() throws HyracksDataException { + public synchronized void clear() throws HyracksDataException { if (!isActive) { throw HyracksDataException.create(ErrorCode.CANNOT_CLEAR_INACTIVE_INDEX); } @@ -572,18 +571,6 @@ public abstract class AbstractLSMIndex implements ILSMIndex { return !memoryComponents.get(currentMutableComponentId.get()).isModified(); } - public void setCurrentMutableComponentState(ComponentState componentState) { - memoryComponents.get(currentMutableComponentId.get()).setState(componentState); - } - - public ComponentState getCurrentMutableComponentState() { - return memoryComponents.get(currentMutableComponentId.get()).getState(); - } - - public int getCurrentMutableComponentWriterCount() { - return memoryComponents.get(currentMutableComponentId.get()).getWriterCount(); - } - @Override public List<ILSMDiskComponent> getInactiveDiskComponents() { return inactiveDiskComponents;