Skip to content

Instantly share code, notes, and snippets.

@itn3000
Last active April 14, 2022 02:20
Show Gist options
  • Save itn3000/9452a468f5e5e2da8b339dc40fd6e5df to your computer and use it in GitHub Desktop.
Save itn3000/9452a468f5e5e2da8b339dc40fd6e5df to your computer and use it in GitHub Desktop.
Exception in iterating FasterLog with FastCommitMode=true
using FASTER.core;
// ensure log directory is empty.
if (Directory.Exists("abc"))
{
Directory.Delete("abc", true);
}
using var fl = new FasterLog(new FasterLogSettings("abc")
{
FastCommitMode = true,
LogChecksum = LogChecksumType.PerEntry,
TryRecoverLatest = true,
}
);
var data = new byte[256];
for (int i = 0; i < 100; i++)
{
fl.Enqueue(data);
}
fl.CommitStrongly(out var commitTail, out var actualCommitNum, spinWait: true);
using var iter = fl.Scan(fl.BeginAddress, fl.TailAddress);
long totalNum = 0;
long totalBytes = 0;
try
{
await foreach (var item in iter.GetAsyncEnumerable())
{
totalNum++;
totalBytes += item.entryLength;
}
}
catch (Exception e)
{
Console.WriteLine($"error in scan:{e}");
}
Console.WriteLine($"{totalNum}, {totalBytes}");
error in scan:FASTER.core.FasterException: Invalid version found during commit recovery
at FASTER.core.FasterLogRecoveryInfo.Initialize(BinaryReader reader)
at FASTER.core.FasterLogScanIterator.GetNext(Byte[]& entry, Int32& entryLength, Int64& currentAddress, Int64& nextAddress)
at FASTER.core.FasterLogScanIterator.GetAsyncEnumerable(CancellationToken token)+MoveNext()
at FASTER.core.FasterLogScanIterator.GetAsyncEnumerable(CancellationToken token)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Program.<Main>$(String[] args) in D:\src\gitrepos\dotnet-sandbox\fasterlabs2\flprev2\Program.cs:line 26
at Program.<Main>$(String[] args) in D:\src\gitrepos\dotnet-sandbox\fasterlabs2\flprev2\Program.cs:line 26
100, 25600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment