Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only truncate AOF if all active stores are checkpointed #461

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 13 additions & 8 deletions libs/server/StoreWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down