public static void checkAndSetFirstLSN(AbstractLSMIndex lsmIndex, ILogManager logManager) throws HyracksDataException { // If the index has an empty memory component, we need to set its first LSN (For soft checkpoint) if (lsmIndex.isCurrentMutableComponentEmpty()) { //prevent transactions from incorrectly setting the first LSN on a modified component by checking the index is still empty synchronized (lsmIndex.getOperationTracker()) { if (lsmIndex.isCurrentMutableComponentEmpty()) { LSMIOOperationCallback ioOpCallback = (LSMIOOperationCallback) lsmIndex.getIOOperationCallback(); ioOpCallback.setFirstLsnForCurrentMemoryComponent(logManager.getAppendLSN()); } } } }
@Override public long getLocalMinFirstLSN() throws HyracksDataException { final IDatasetLifecycleManager datasetLifecycleManager = appCtx.getDatasetLifecycleManager(); List<IIndex> openIndexList = datasetLifecycleManager.getOpenResources(); long firstLSN; //the min first lsn can only be the current append or smaller long minFirstLSN = logMgr.getAppendLSN(); if (!openIndexList.isEmpty()) { for (IIndex index : openIndexList) { LSMIOOperationCallback ioCallback = (LSMIOOperationCallback) ((ILSMIndex) index).getIOOperationCallback(); if (!((AbstractLSMIndex) index).isCurrentMutableComponentEmpty() || ioCallback.hasPendingFlush()) { firstLSN = ioCallback.getPersistenceLsn(); minFirstLSN = Math.min(minFirstLSN, firstLSN); } } } return minFirstLSN; }