Skip to content

Commit

Permalink
Property that force to remove stores form env before compaction was a…
Browse files Browse the repository at this point in the history
…dded.
  • Loading branch information
andrii0lomakin committed Jan 24, 2024
1 parent 2639b3c commit 24346ef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
18 changes: 16 additions & 2 deletions environment/src/main/kotlin/jetbrains/exodus/env/Environments.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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} " +
Expand Down Expand Up @@ -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()
}

Expand Down
12 changes: 12 additions & 0 deletions openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 24346ef

Please sign in to comment.