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

[C#] Slight modification in Guid allocator within DeviceLogCommitChec… #532

Merged
merged 1 commit into from
Jul 27, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace FASTER.core
/// </summary>
public class DeviceLogCommitCheckpointManager : ILogCommitManager, ICheckpointManager
{
const int indexTokenCount = 2;
const int logTokenCount = 1;

private readonly INamedDeviceFactory deviceFactory;
private readonly ICheckpointNamingScheme checkpointNamingScheme;
private readonly SemaphoreSlim semaphore;
Expand Down Expand Up @@ -60,7 +63,7 @@ public DeviceLogCommitCheckpointManager(INamedDeviceFactory deviceFactory, IChec
// later log checkpoint to work with
indexTokenHistory = new Guid[2];
// We only keep the latest log checkpoint
logTokenHistory = new Guid[1];
logTokenHistory = new Guid[2];
}
this._disposed = false;

Expand Down Expand Up @@ -206,7 +209,7 @@ public unsafe void CommitIndexCheckpoint(Guid indexToken, byte[] commitMetadata)
{
var prior = indexTokenHistory[indexTokenHistoryOffset];
indexTokenHistory[indexTokenHistoryOffset] = indexToken;
indexTokenHistoryOffset = (indexTokenHistoryOffset + 1) % indexTokenHistory.Length;
indexTokenHistoryOffset = (indexTokenHistoryOffset + 1) % indexTokenCount;
if (prior != default)
deviceFactory.Delete(checkpointNamingScheme.IndexCheckpointBase(prior));
}
Expand Down Expand Up @@ -253,7 +256,7 @@ public unsafe void CommitLogCheckpoint(Guid logToken, byte[] commitMetadata)
{
var prior = logTokenHistory[logTokenHistoryOffset];
logTokenHistory[logTokenHistoryOffset] = logToken;
logTokenHistoryOffset = (logTokenHistoryOffset + 1) % logTokenHistory.Length;
logTokenHistoryOffset = (logTokenHistoryOffset + 1) % logTokenCount;
if (prior != default)
deviceFactory.Delete(checkpointNamingScheme.LogCheckpointBase(prior));
}
Expand Down Expand Up @@ -366,12 +369,12 @@ public void OnRecovery(Guid indexToken, Guid logToken)
if (indexToken != default)
{
indexTokenHistory[indexTokenHistoryOffset] = indexToken;
indexTokenHistoryOffset = (indexTokenHistoryOffset + 1) % indexTokenHistory.Length;
indexTokenHistoryOffset = (indexTokenHistoryOffset + 1) % indexTokenCount;
}
if (logToken != default)
{
logTokenHistory[logTokenHistoryOffset] = logToken;
logTokenHistoryOffset = (logTokenHistoryOffset + 1) % logTokenHistory.Length;
logTokenHistoryOffset = (logTokenHistoryOffset + 1) % logTokenCount;
}

// Purge all log checkpoints that were not used for recovery
Expand Down