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 f9ca6ce002..51eccb6203 100644 --- a/libs/server/StoreWrapper.cs +++ b/libs/server/StoreWrapper.cs @@ -719,15 +719,20 @@ private async Task InitiateCheckpoint(bool full, CheckpointType checkpointType, objectStoreCheckpointResult = await objectStore.TakeHybridLogCheckpointAsync(checkpointType, tryIncremental); } - // If cluster is enabled the replication manager is responsible for truncating AOF - if (serverOptions.EnableCluster && serverOptions.EnableAOF) { - clusterProvider.SafeTruncateAOF(storeType, full, CheckpointCoveredAofAddress, storeCheckpointResult.token, objectStoreCheckpointResult.token); - } - else - { - appendOnlyFile?.TruncateUntil(CheckpointCoveredAofAddress); - appendOnlyFile?.Commit(); + // If cluster is enabled the replication manager is responsible for truncating AOF + if (serverOptions.EnableCluster && serverOptions.EnableAOF) + { + clusterProvider.SafeTruncateAOF(storeType, full, CheckpointCoveredAofAddress, storeCheckpointResult.token, objectStoreCheckpointResult.token); + } + else + { + if (storeType == StoreType.All || (storeType == StoreType.Main && serverOptions.DisableObjects)) + { + appendOnlyFile?.TruncateUntil(CheckpointCoveredAofAddress); + appendOnlyFile?.Commit(); + } + } } if (objectStore != null)