microsoft / FASTER

Fast persistent recoverable log and key-value store + cache, in C# and C++.
https://aka.ms/FASTER
MIT License
6.29k stars 563 forks source link

FasterLog.CommitAsync will missing iterator offset if iterator does not call CompleteUntil before #915

Open cocosip opened 4 months ago

cocosip commented 4 months ago
using var iter = log.Scan(0, long.MaxValue, "foo", recover: true);
while (iter.GetNext(out var result, out var length, out var currentAddress, out nextAddress))
{
    // THIS WAITASYNC BELOW HANGS
    if (await iter.WaitAsync())
    {
        Console.WriteLine("read data currentAddress:{0}, nextAddress :{1}, content:{2}", currentAddress, nextAddress, Encoding.UTF8.GetString(result));
      //iter.CompleteUntil(nextAddress)
       await iter.CompleteUntilRecordAtAsync(currentAddress);
    }
}
 await log.CommitAsync();

If not call iter.CompleteUntil or iter.CompleteUntilRecordAtAsync , the iterator offset will missing when after next restart. How can i ensure CompleteUntilRecordAtAsync/CompleteUntil has called?