Skip to content

Commit

Permalink
Allow truncation if main store is checkpointed and object store is di…
Browse files Browse the repository at this point in the history
…sabled
  • Loading branch information
chenhao-ye committed Jun 13, 2024
1 parent dc6bc16 commit 49af328
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions libs/cluster/Server/ClusterProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions libs/server/StoreWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
}
}
}

Expand Down

0 comments on commit 49af328

Please sign in to comment.