From 49af328b9a9a47e14b915cbd41995604ac8e9237 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Thu, 13 Jun 2024 22:04:21 +0000 Subject: [PATCH] Allow truncation if main store is checkpointed and object store is disabled --- libs/cluster/Server/ClusterProvider.cs | 4 ++++ libs/server/StoreWrapper.cs | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/cluster/Server/ClusterProvider.cs b/libs/cluster/Server/ClusterProvider.cs index b9636242a2..9153f0cb5c 100644 --- a/libs/cluster/Server/ClusterProvider.cs +++ b/libs/cluster/Server/ClusterProvider.cs @@ -156,6 +156,10 @@ public void SafeTruncateAOF(StoreType storeType, bool full, long CheckpointCover // Used to delete old checkpoints and cleanup and also cleanup during attachment to new primary replicationManager.AddCheckpointEntry(entry, storeType, full); + // Only truncate AOF if 1) both stores were checkpointed OR 2) only Main was checkpointed but Object was not enabled + if (storeType != StoreType.All && !(storeType == StoreType.Main && serverOptions.DisableObjects)) + return; + if (clusterManager.CurrentConfig.LocalNodeRole == NodeRole.PRIMARY) _ = replicationManager.SafeTruncateAof(CheckpointCoveredAofAddress); else diff --git a/libs/server/StoreWrapper.cs b/libs/server/StoreWrapper.cs index ce84ac6da3..c65aa2e3eb 100644 --- a/libs/server/StoreWrapper.cs +++ b/libs/server/StoreWrapper.cs @@ -693,8 +693,6 @@ private async Task InitiateCheckpoint(bool full, CheckpointType checkpointType, objectStoreCheckpointResult = await objectStore.TakeHybridLogCheckpointAsync(checkpointType, tryIncremental); } - // Only truncate AOF if both stores are checkpointed - if (storeType == StoreType.All) { // If cluster is enabled the replication manager is responsible for truncating AOF if (serverOptions.EnableCluster && serverOptions.EnableAOF) @@ -703,8 +701,11 @@ private async Task InitiateCheckpoint(bool full, CheckpointType checkpointType, } else { - appendOnlyFile?.TruncateUntil(CheckpointCoveredAofAddress); - appendOnlyFile?.Commit(); + if (storeType == StoreType.All || (storeType == StoreType.Main && serverOptions.DisableObjects)) + { + appendOnlyFile?.TruncateUntil(CheckpointCoveredAofAddress); + appendOnlyFile?.Commit(); + } } }