Skip to content

Commit

Permalink
IGNITE-19904 Fix assertion on defragmentation - Fixes #10866.
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksey Plekhanov <[email protected]>
  • Loading branch information
Vladsz83 authored and alex-plekhanov committed Aug 4, 2023
1 parent de08e0c commit c1b1aa4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,10 @@ private long[] calculateFragmentSizes(String regionName, int concLvl, long cache
chpBufSize = cacheSize;
}

// TODO IGNITE-20138 : Should be actual checkpoint lock checker, related to the checkpointer for this data
// region. Like LightweightCheckpointManager#checkpointer for the defragmentation.
CheckpointLockStateChecker chpLockChecker = this;

PageMemoryImpl pageMem = new PageMemoryImpl(
wrapMetricsPersistentMemoryProvider(memProvider, regMetrics),
calculateFragmentSizes(
Expand All @@ -1220,10 +1224,12 @@ private long[] calculateFragmentSizes(String regionName, int concLvl, long cache
// Write page to disk.
pageMgr.write(fullId.groupId(), fullId.pageId(), pageBuf, tag, true);

// TODO IGNITE-20138 : Should be actual checkpointer, related to this data rageion. Like
// LightweightCheckpointManager#checkpointer for the defragmentation.
getCheckpointer().currentProgress().updateEvictedPages(1);
},
trackable,
this,
chpLockChecker,
regMetrics,
regCfg,
resolveThrottlingPolicy(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.ignite.internal.processors.cache.persistence.GridCacheOffheapManager.GridCacheDataStore;
import org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointManager;
import org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointTimeoutLock;
import org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpointer;
import org.apache.ignite.internal.processors.cache.persistence.checkpoint.LightweightCheckpointManager;
import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
import org.apache.ignite.internal.processors.cache.persistence.file.FileVersionCheckingFactory;
Expand Down Expand Up @@ -209,10 +210,12 @@ public CachePartitionDefragmentationManager(
new LinkedBlockingQueue<>()
);

completionFut.listen(future -> {
completionFut.chain(future -> {
linkMapByPart.values().forEach(LinkMap::close);

linkMapByPart.clear();

return future.result();
});
}

Expand All @@ -225,6 +228,19 @@ public void beforeDefragmentation() throws IgniteCheckedException {

nodeCheckpoint.forceCheckpoint("beforeDefragmentation", null).futureFor(FINISHED).get();

// The concurrent default checkpointer has various listeners, interferes with new dedicated
// CacheGroupContext for defragmentation and at least clears shared CheckpointProgress#clearCounters().
// Should be properly reconfigured and restarted after the defragmentation task to have ability launch
// other maintenance tasks after.
Checkpointer defaultCheckpointer = nodeCheckpoint.getCheckpointer();

if (defaultCheckpointer != null && !defaultCheckpointer.isDone()) {
if (log.isDebugEnabled())
log.debug("Stopping default checkpointer.");

defaultCheckpointer.shutdownNow();
}

dbMgr.preserveWalTailPointer();

sharedCtx.wal().onDeActivate(sharedCtx.kernalContext());
Expand Down Expand Up @@ -322,8 +338,6 @@ public void executeDefragmentation() throws IgniteCheckedException {
cacheDataStores.put(store.partId(), store);
}

dbMgr.checkpointedDataRegions().remove(oldGrpCtx.dataRegion());

// Another cheat. Ttl cleanup manager knows too much shit.
oldGrpCtx.caches().stream()
.filter(cacheCtx -> cacheCtx.groupId() == grpId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static int releasePage(long absPtr) {
* @return Number of acquires for the page.
*/
public static int pinCount(long absPtr) {
return GridUnsafe.getIntVolatile(null, absPtr);
return GridUnsafe.getIntVolatile(null, absPtr + PAGE_PIN_CNT_OFFSET);
}

/**
Expand Down

0 comments on commit c1b1aa4

Please sign in to comment.