Skip to content

Commit

Permalink
Make log compaction local in embedded journal
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?
Making `RaftServerConfigKeys.Log.setPurgeUptoSnapshotIndex` to `true` by
default. This enables each master in the quorum to look only at the
local snapshots it possesses in order to determine which log files to
prune.
Before, masters would only prune based on the quorum consensus of
committed log index.

### Why are the changes needed?
Community members have noticed that Ratis logs grow unbounded in the
presence of a slow master, which can crash certain masters when the UFS
runs out of space in extreme cases.

### Does this PR introduce any user facing changes?
Adds a `PropertyKey` to enable or disable this new feature.

pr-link: #15245
change-id: cid-7fe8e99f52b170f1bea9027f572b77aae2eea00c
  • Loading branch information
jenoudet committed Apr 1, 2022
1 parent b3c638f commit 662c9c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/common/src/main/java/alluxio/conf/PropertyKey.java
Expand Up @@ -2582,6 +2582,14 @@ public String toString() {
.setConsistencyCheckLevel(ConsistencyCheckLevel.WARN)
.setScope(Scope.MASTER)
.build();
public static final PropertyKey MASTER_JOURNAL_LOCAL_LOG_COMPACTION =
booleanBuilder(Name.MASTER_JOURNAL_LOCAL_LOG_COMPACTION)
.setDefaultValue(true)
.setDescription("Whether to employ a quorum level log compaction policy or a "
+ "local (individual) log compaction policy.")
.setConsistencyCheckLevel(ConsistencyCheckLevel.WARN)
.setScope(Scope.MASTER)
.build();
public static final PropertyKey MASTER_JOURNAL_GC_PERIOD_MS =
durationBuilder(Name.MASTER_JOURNAL_GC_PERIOD_MS)
.setAlias("alluxio.master.journal.gc.period.ms")
Expand Down Expand Up @@ -6799,6 +6807,8 @@ public static final class Name {
public static final String MASTER_WORKER_TIMEOUT_MS = "alluxio.master.worker.timeout";
public static final String MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES =
"alluxio.master.journal.checkpoint.period.entries";
public static final String MASTER_JOURNAL_LOCAL_LOG_COMPACTION =
"alluxio.master.journal.local.log.compaction";
public static final String MASTER_JOURNAL_GC_PERIOD_MS = "alluxio.master.journal.gc.period";
public static final String MASTER_JOURNAL_GC_THRESHOLD_MS =
"alluxio.master.journal.gc.threshold";
Expand Down
Expand Up @@ -377,6 +377,14 @@ private synchronized void initServer() throws IOException {
RaftServerConfigKeys.Snapshot.setAutoTriggerThreshold(properties,
snapshotAutoTriggerThreshold);

if (ServerConfiguration.global().getBoolean(PropertyKey.MASTER_JOURNAL_LOCAL_LOG_COMPACTION)) {
// purges log files after taking a snapshot successfully
RaftServerConfigKeys.Log.setPurgeUptoSnapshotIndex(properties, true);
// leaves no gap between log file purges: all log files included in a newly installed
// snapshot are purged right away
RaftServerConfigKeys.Log.setPurgeGap(properties, 1);
}

RaftServerConfigKeys.Log.Appender.setInstallSnapshotEnabled(
properties, false);

Expand Down

0 comments on commit 662c9c9

Please sign in to comment.