Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-19950 Creation of cache dump implemented #10936

Merged
merged 74 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
18f8278
IGNITE-19950 WIP
nizhikov Jul 12, 2023
80e8b84
IGNITE-19950 WIP
nizhikov Jul 12, 2023
e2b9264
IGNITE-19950 WIP
nizhikov Jul 18, 2023
e698ed6
IGNITE-19950 WIP
nizhikov Jul 27, 2023
9ba0280
IGNITE-19950 WIP
nizhikov Jul 27, 2023
7300b47
IGNITE-19950 Save metadata implemented
nizhikov Jul 27, 2023
dcb9e81
IGNITE-19950 Dump creation process implemented
nizhikov Jul 28, 2023
be062a7
IGNITE-19950 Dump creation process implemented
nizhikov Jul 28, 2023
b275a98
IGNITE-19950 Stub for dump creation process implemented
nizhikov Jul 28, 2023
42c1489
Merge branch 'master' into IGNITE-19950-snapshot-merge
nizhikov Aug 11, 2023
370edae
Merge branch 'master' into IGNITE-19950-snapshot-merge
nizhikov Aug 16, 2023
a55bc15
IGNITE-19950 WIP
nizhikov Aug 21, 2023
8f0b873
Merge branch 'master' into IGNITE-19950-snapshot-merge
nizhikov Aug 21, 2023
4e0bd99
IGNITE-19950 Creation seems to be complete
nizhikov Aug 23, 2023
00f53af
Merge branch 'master' into IGNITE-19950
nizhikov Aug 23, 2023
7aeca21
IGNITE-19950 Tests improvements
nizhikov Aug 24, 2023
b87338d
IGNITE-19950 Tests improvements
nizhikov Aug 28, 2023
2b81128
IGNITE-19950 Tests improvements
nizhikov Aug 28, 2023
a64d1cf
IGNITE-19950 Tests improvements
nizhikov Aug 28, 2023
a343bd1
IGNITE-19950 Tests improvements
nizhikov Aug 28, 2023
0bb66b5
Merge branch 'master' into IGNITE-19950
nizhikov Aug 28, 2023
725837c
IGNITE-19950 Tests improvements
nizhikov Aug 29, 2023
0418b46
IGNITE-19950 Tests improvements
nizhikov Aug 30, 2023
289bc27
IGNITE-19950 Restore WIP
nizhikov Aug 30, 2023
10059d8
IGNITE-19950 Test improvements
nizhikov Aug 30, 2023
1a37683
IGNITE-19950 Revert unnecessary changes.
nizhikov Aug 30, 2023
f6049cc
IGNITE-19950 Per partition parallelism
nizhikov Aug 30, 2023
fa8d34c
IGNITE-19950 Per partition parallelism
nizhikov Aug 30, 2023
42dbe75
IGNITE-19950 Tests improvements.
nizhikov Aug 30, 2023
d48c179
Merge branch 'master' into IGNITE-19950
nizhikov Aug 31, 2023
f754d9b
IGNITE-19950 Code improvements
nizhikov Aug 31, 2023
22f709d
IGNITE-19950 Remove restore code.
nizhikov Aug 31, 2023
1386384
IGNITE-19950 CRC check added.
nizhikov Aug 31, 2023
4b4b513
IGNITE-19950 Code review fixes.
nizhikov Aug 31, 2023
e23358a
IGNITE-19950 Code review fixes.
nizhikov Aug 31, 2023
53afadf
IGNITE-19950 Code review fixes.
nizhikov Aug 31, 2023
b36ebe5
IGNITE-19950 Code review fixes.
nizhikov Aug 31, 2023
d32df43
IGNITE-19950 Test improvements
nizhikov Aug 31, 2023
ca593e3
IGNITE-19950 Test improvements
nizhikov Aug 31, 2023
2d56981
IGNITE-19950 Test improvements
nizhikov Aug 31, 2023
1520fc5
IGNITE-19950 Code review fixes
nizhikov Sep 1, 2023
70a0a22
IGNITE-19950 Tests improvements
nizhikov Sep 1, 2023
884bfc8
IGNITE-19950 Tests improvements
nizhikov Sep 1, 2023
a0dceec
IGNITE-19950 Tests improvements
nizhikov Sep 1, 2023
56666f1
IGNITE-19950 Tests improvements
nizhikov Sep 1, 2023
8ad229d
Merge branch 'master' into IGNITE-19950
nizhikov Sep 5, 2023
f830bf5
IGNITE-19950 Code review fixes
nizhikov Sep 5, 2023
ac895e8
IGNITE-19950 Bug fix
nizhikov Sep 5, 2023
d24e3f2
Merge branch 'master' into IGNITE-19950
nizhikov Sep 11, 2023
e8f11d3
IGNITE-19950 Code review fixes
nizhikov Sep 11, 2023
e68751f
IGNITE-19950 Code review fixes
nizhikov Sep 11, 2023
6eaf5da
ISE-2839 Code review fixes
nizhikov Sep 11, 2023
2019898
IGNITE-19950 Tests added
nizhikov Sep 11, 2023
1ff78e7
IGNITE-19950 Tests added
nizhikov Sep 11, 2023
522d28f
IGNITE-19950 Code review fixes
nizhikov Sep 12, 2023
0d1cf9a
IGNITE-19950 Code review fixes
nizhikov Sep 12, 2023
53aa06a
IGNITE-19950 Code review fixes
nizhikov Sep 12, 2023
d16122f
IGNITE-19950 Code review fixes
nizhikov Sep 12, 2023
bfce6ce
Merge branch 'master' into IGNITE-19950
nizhikov Sep 15, 2023
929b6b4
IGNITE-19950 Code review changes.
nizhikov Sep 18, 2023
d9025e1
IGNITE-19950 Code review changes.
nizhikov Sep 18, 2023
49a07b4
IGNITE-19950 Code review changes.
nizhikov Sep 18, 2023
6347932
IGNITE-19950 Tests fixes.
nizhikov Sep 18, 2023
c22205c
IGNITE-19950 Tests fixes.
nizhikov Sep 18, 2023
30b40a5
IGNITE-19950 Tests fixes.
nizhikov Sep 18, 2023
1285fff
IGNITE-19950 Tests fixes.
nizhikov Sep 19, 2023
b50b072
IGNITE-19950 Tests fixes.
nizhikov Sep 19, 2023
f749811
IGNITE-19950 Tests fixes.
nizhikov Sep 19, 2023
4afaca3
IGNITE-19950 NPE fix
nizhikov Sep 20, 2023
e35d76f
IGNITE-19950 Tests fix
nizhikov Sep 21, 2023
c231ebb
IGNITE-19950 Code review fixes
nizhikov Sep 21, 2023
a0f875e
IGNITE-19950 Code review fixes
nizhikov Sep 21, 2023
bb424f5
IGNITE-19950 Code review fixes
nizhikov Sep 21, 2023
42058e3
IGNITE-19950 Code review fixes
nizhikov Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ public void testGetAllView() throws Exception {
new TreeSet<>(Arrays.asList(
"SYS.METRICS",
"SYS.SERVICES",
"SYS.SNAPSHOT",
"SYS.CACHE_GROUPS",
"SYS.CACHES",
"SYS.TASKS",
Expand Down Expand Up @@ -896,6 +897,13 @@ public void testGetAllColumns() throws Exception {
"SYS.SERVICES.STATICALLY_CONFIGURED.null",
"SYS.SERVICES.SERVICE_ID.null",
"SYS.SERVICES.TOPOLOGY_SNAPSHOT.null",
"SYS.SNAPSHOT.BASELINE_NODES.null",
"SYS.SNAPSHOT.CACHE_GROUPS.null",
"SYS.SNAPSHOT.CONSISTENT_ID.null",
"SYS.SNAPSHOT.INCREMENT_INDEX.null",
"SYS.SNAPSHOT.NAME.null",
"SYS.SNAPSHOT.SNAPSHOT_RECORD_SEGMENT.null",
"SYS.SNAPSHOT.TYPE.null",
"SYS.TASKS.AFFINITY_CACHE_NAME.null",
"SYS.TASKS.INTERNAL.null",
"SYS.TASKS.END_TIME.null",
Expand Down
12 changes: 12 additions & 0 deletions modules/core/src/main/java/org/apache/ignite/IgniteSnapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* <li>Concurrent updates from {@link IgniteDataStreamer} with default {@link IgniteDataStreamer#allowOverwrite()}
* setting (false) into a persistent cache can cause that cache data stored inconsistent.</li>
* </ul>
* You can create cache dump, also. Cache dump is consistent files consist of entry by entry cache content.
* This type of snapshots supports in-memory caches.
*/
public interface IgniteSnapshot {
/**
Expand Down Expand Up @@ -61,6 +63,16 @@ public interface IgniteSnapshot {
*/
public IgniteFuture<Void> cancelSnapshot(String name);

/**
* Creates cache groups dump.
* Dump is consistent entry by entry backup of cache group content.
* In-memory cache groups also supported.
*
* @param name Dump name.
* @return Future which will be completed when dump ends.
*/
public IgniteFuture<Void> createDump(String name);

/**
* Restore cache group(s) from the snapshot.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrManager;
import org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter;
import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.DumpEntryChangeListener;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager;
import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
Expand Down Expand Up @@ -114,6 +115,7 @@
import org.apache.ignite.plugin.security.SecurityException;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISABLE_TRIGGERING_CACHE_INTERCEPTOR_ON_CONFLICT;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_READ_LOAD_BALANCING;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
Expand Down Expand Up @@ -283,6 +285,9 @@ public class GridCacheContext<K, V> implements Externalizable {
/** Recovery mode flag. */
private volatile boolean recoveryMode;

/** Dump callback. */
private volatile DumpEntryChangeListener dumpLsnr;

/** */
private final boolean disableTriggeringCacheInterceptorOnConflict =
Boolean.parseBoolean(System.getProperty(IGNITE_DISABLE_TRIGGERING_CACHE_INTERCEPTOR_ON_CONFLICT, "false"));
Expand Down Expand Up @@ -2348,6 +2353,19 @@ public AtomicReference<IgniteInternalFuture<Boolean>> lastRemoveAllJobFut() {
return lastRmvAllJobFut;
}

/** */
public DumpEntryChangeListener dumpListener() {
return dumpLsnr;
}

/** */
public void dumpListener(DumpEntryChangeListener dumpEntryChangeLsnr) {
assert this.dumpLsnr == null || dumpEntryChangeLsnr == null;
assert cacheType == CacheType.USER;

this.dumpLsnr = dumpEntryChangeLsnr;
nizhikov marked this conversation as resolved.
Show resolved Hide resolved
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeString(out, igniteInstanceName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter;
import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
import org.apache.ignite.internal.processors.cache.persistence.StorageException;
import org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.DumpEntryChangeListener;
import org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryListener;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
Expand Down Expand Up @@ -1542,6 +1543,11 @@ else if (interceptorVal != val0)
assert ttl >= 0 : ttl;
assert expireTime >= 0 : expireTime;

DumpEntryChangeListener dumpLsnr = cctx.dumpListener();

if (dumpLsnr != null)
dumpLsnr.beforeChange(cctx, key, old, extras == null ? CU.EXPIRE_TIME_ETERNAL : extras.expireTime(), ver);

// Detach value before index update.
val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);

Expand Down Expand Up @@ -1735,6 +1741,11 @@ protected Object keyValue(boolean cpy) {
}
}

DumpEntryChangeListener dumpLsnr = cctx.dumpListener();

if (dumpLsnr != null)
dumpLsnr.beforeChange(cctx, key, old, extras == null ? CU.EXPIRE_TIME_ETERNAL : extras.expireTime(), ver);

removeValue();

update(null, 0, 0, newVer, true);
Expand Down Expand Up @@ -3734,6 +3745,11 @@ private boolean onExpired(CacheObject expiredVal, GridCacheVersion obsoleteVer)
if (mvccExtras() != null)
return false;

DumpEntryChangeListener dumpLsnr = cctx.dumpListener();

if (dumpLsnr != null)
dumpLsnr.beforeChange(cctx, key, expiredVal, extras == null ? CU.TTL_MINIMUM : extras.expireTime(), ver);

if (cctx.deferredDelete() && !detached() && !isInternal()) {
if (!deletedUnlocked() && !isStartVersion()) {
update(null, 0L, 0L, ver, true);
Expand Down Expand Up @@ -6143,6 +6159,18 @@ else if (interceptorVal != updated0) {
}
}

DumpEntryChangeListener dumpLsnr = cctx.dumpListener();

if (dumpLsnr != null) {
dumpLsnr.beforeChange(
cctx,
entry.key,
oldVal,
entry.extras == null ? CU.EXPIRE_TIME_ETERNAL : entry.extras.expireTime(),
entry.ver
);
}

updated = cctx.kernalContext().cacheObjects().prepareForCache(updated, cctx);

if (writeThrough)
Expand Down Expand Up @@ -6246,6 +6274,18 @@ private void remove(@Nullable GridCacheVersionConflictContext<?, ?> conflictCtx,
}
}

DumpEntryChangeListener dumpLsnr = cctx.dumpListener();

if (dumpLsnr != null) {
dumpLsnr.beforeChange(
cctx,
entry.key,
oldVal,
entry.extras == null ? CU.EXPIRE_TIME_ETERNAL : entry.extras.expireTime(),
entry.ver
);
}

if (writeThrough)
// Must persist inside synchronization in non-tx mode.
cctx.store().remove(null, entry.key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,12 @@ private boolean inMemoryCdcCache(CacheConfiguration<?, ?> cfg) {
public File cacheConfigurationFile(CacheConfiguration<?, ?> ccfg) {
File cacheWorkDir = cacheWorkDir(ccfg);

return ccfg.getGroupName() == null ? new File(cacheWorkDir, CACHE_DATA_FILENAME) :
new File(cacheWorkDir, ccfg.getName() + CACHE_DATA_FILENAME);
return new File(cacheWorkDir, cacheDataFilename(ccfg));
}

/** @return Name of cache data filename. */
public static String cacheDataFilename(CacheConfiguration<?, ?> ccfg) {
return ccfg.getGroupName() == null ? CACHE_DATA_FILENAME : (ccfg.getName() + CACHE_DATA_FILENAME);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,35 +82,40 @@ class BinaryMetadataFileStore {
* @param log Logger.
* @param binaryMetadataFileStoreDir Path to binary metadata store configured by user, should include binary_meta
* and consistentId.
* @param forceEnabled If {@code true} then will write files even if persistence and CDC disabled.
*/
BinaryMetadataFileStore(
final ConcurrentMap<Integer, BinaryMetadataHolder> metadataLocCache,
final GridKernalContext ctx,
final IgniteLogger log,
final File binaryMetadataFileStoreDir
final File binaryMetadataFileStoreDir,
final boolean forceEnabled
) throws IgniteCheckedException {
this.metadataLocCache = metadataLocCache;
this.ctx = ctx;

enabled = CU.isPersistenceEnabled(ctx.config()) || CU.isCdcEnabled(ctx.config());
enabled = forceEnabled || CU.isPersistenceEnabled(ctx.config()) || CU.isCdcEnabled(ctx.config());

this.log = log;

if (!enabled)
return;

fileIOFactory = ctx.config().getDataStorageConfiguration().getFileIOFactory();
DataStorageConfiguration dsCfg = ctx.config().getDataStorageConfiguration();

fileIOFactory = dsCfg == null ? new DataStorageConfiguration().getFileIOFactory() : dsCfg.getFileIOFactory();

final String nodeFolderName = ctx.pdsFolderResolver().resolveFolders().folderName();

if (binaryMetadataFileStoreDir != null)
metadataDir = binaryMetadataFileStoreDir;
else
else {
metadataDir = new File(U.resolveWorkDirectory(
ctx.config().getWorkDirectory(),
DataStorageConfiguration.DFLT_BINARY_METADATA_PATH,
false
), nodeFolderName);
}

fixLegacyFolder(nodeFolderName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ public static File binaryWorkDir(String igniteWorkDir, String consId) {
CU.isPersistenceEnabled(ctx.config()) && binaryMetadataFileStoreDir == null ?
resolveBinaryWorkDir(ctx.config().getWorkDirectory(),
ctx.pdsFolderResolver().resolveFolders().folderName()) :
binaryMetadataFileStoreDir);
binaryMetadataFileStoreDir,
false);

metadataFileStore.start();
}
Expand Down Expand Up @@ -1019,7 +1020,9 @@ public BinaryMetadata binaryMetadata(int typeId) throws BinaryObjectException {
ctx,
log,
resolveBinaryWorkDir(dir.getAbsolutePath(),
ctx.pdsFolderResolver().resolveFolders().folderName()));
ctx.pdsFolderResolver().resolveFolders().folderName()),
true
);

for (BinaryType type : types)
writer.mergeAndWriteMetadata(((BinaryTypeImpl)type).metadata());
Expand All @@ -1037,7 +1040,7 @@ public BinaryMetadata binaryMetadata(int typeId) throws BinaryObjectException {
try {
ConcurrentMap<Integer, BinaryMetadataHolder> metaCache = new ConcurrentHashMap<>();

new BinaryMetadataFileStore(metaCache, ctx, log, metadataDir)
new BinaryMetadataFileStore(metaCache, ctx, log, metadataDir, false)
.restoreMetadata();

Collection<BinaryMetadata> metadata = F.viewReadOnly(metaCache.values(), BinaryMetadataHolder::metadata);
Expand Down Expand Up @@ -1073,7 +1076,7 @@ public BinaryMetadata binaryMetadata(int typeId) throws BinaryObjectException {

ConcurrentMap<Integer, BinaryMetadataHolder> metaCache = new ConcurrentHashMap<>();

new BinaryMetadataFileStore(metaCache, ctx, log, metadataDir).restoreMetadata(typeId);
new BinaryMetadataFileStore(metaCache, ctx, log, metadataDir, false).restoreMetadata(typeId);

addMetaLocally(typeId, metaCache.get(typeId).metadata().wrap(binaryContext()), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,14 +916,23 @@ public static int partId(String partFileName) {
* @return List of cache partitions in given directory.
*/
public static List<File> cachePartitionFiles(File cacheDir) {
return cachePartitionFiles(cacheDir, FILE_SUFFIX);
}

/**
* @param cacheDir Cache directory to check.
* @param ext File extension.
* @return List of cache partitions in given directory.
*/
public static List<File> cachePartitionFiles(File cacheDir, String ext) {
File[] files = cacheDir.listFiles();

if (files == null)
return Collections.emptyList();

return Arrays.stream(files)
.filter(File::isFile)
.filter(f -> f.getName().endsWith(FILE_SUFFIX))
.filter(f -> f.getName().endsWith(ext))
.collect(Collectors.toList());
}

Expand Down
Loading