diff --git a/environment/src/main/kotlin/jetbrains/exodus/env/Environments.kt b/environment/src/main/kotlin/jetbrains/exodus/env/Environments.kt index b3d435429..524a192d9 100644 --- a/environment/src/main/kotlin/jetbrains/exodus/env/Environments.kt +++ b/environment/src/main/kotlin/jetbrains/exodus/env/Environments.kt @@ -146,6 +146,18 @@ object Environments : KLogging() { if (ec.logDataReaderWriterProvider == DataReaderWriterProvider.DEFAULT_READER_WRITER_PROVIDER && (ec.envCompactOnOpen || ec.envCompactInSingleBatchOnOpen) && env.log.numberOfFiles > 1 || needsToBeMigrated ) { + if (env.environmentConfig.storesToRemoveBeforeCompaction != null) { + env.executeInTransaction { tx -> + val storesToRemove = env.environmentConfig.storesToRemoveBeforeCompaction.split(",") + + for(storeToRemove in storesToRemove) { + env.removeStore(storeToRemove, tx) + } + } + EnvironmentImpl.loggerInfo( + "Store(s) ${env.environmentConfig.storesToRemoveBeforeCompaction} was(were) removed from the database." + ) + } if (needsToBeMigrated) { EnvironmentImpl.loggerInfo( "Outdated binary format is used in environment ${env.log.location} " + @@ -307,8 +319,10 @@ object Environments : KLogging() { } if (env.environmentConfig.checkDataStructuresConsistency) { - logger.warn("Data structures consistency is going to be checked because setting " + - EnvironmentConfig.ENV_CHECK_DATA_STRUCTURES_CONSISTENCY + " is set to true") + logger.warn( + "Data structures consistency is going to be checked because setting " + + EnvironmentConfig.ENV_CHECK_DATA_STRUCTURES_CONSISTENCY + " is set to true" + ) (env as EnvironmentImpl).checkDataStructuresConsistency() } diff --git a/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java b/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java index bcdeb757b..aaf9dc67d 100644 --- a/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java +++ b/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java @@ -436,6 +436,11 @@ public EnvironmentConfig setMutable(boolean isMutable) { */ public static final String ENV_CHECK_BACKUP_CONSISTENCY = "exodus.env.checkBackupConsistency"; + /** + * List of stores to remove before compaction is started on environment. + */ + public static final String ENV_STORES_TO_REMOVE_BEFORE_COMPACTION = "exodus.env.StoresToRemoveBeforeCompaction"; + public static final String ENV_CHECK_DATA_STRUCTURES_CONSISTENCY = "exodus.env.checkDataStructuresConsistency"; /** @@ -1854,6 +1859,13 @@ public boolean getEnvCloseForcedly() { return (Boolean) getSetting(ENV_CLOSE_FORCEDLY); } + /** + * List of stores to remove before compaction is started on environment. + */ + public String getStoresToRemoveBeforeCompaction() { + return (String) getSetting(ENV_STORES_TO_REMOVE_BEFORE_COMPACTION); + } + /** * Set {@code true} if {@linkplain Environment#close()} shouldn't check if there are unfinished * transactions. Set {@code false} if it should check and throw {@linkplain ExodusException} if there are unfinished