Skip to content

Commit

Permalink
Managedlocalstorage fixes (#209)
Browse files Browse the repository at this point in the history
* Improved ManagedLocalStorageDevice to use ReadAsync and WriteAsync.
* Added fcntl calls for non-windows machines.
* On non-windows, serialize writes so that a second write is issued on handle only after previous write completes and enters completion callback. Without this restriction, we see incorrect data (zeros) flushed to the log. Needs further investigation in future.
  • Loading branch information
badrishc committed Nov 18, 2019
1 parent 98889ae commit ff51d3c
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 167 deletions.
13 changes: 10 additions & 3 deletions cs/playground/FasterLogSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using FASTER.core;
Expand Down Expand Up @@ -30,7 +31,13 @@ static void Main()
staticEntry[i] = (byte)i;
}

var device = Devices.CreateLogDevice("D:\\logs\\hlog.log");
IDevice device;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
device = Devices.CreateLogDevice("D:\\logs\\hlog.log");
else
device = Devices.CreateLogDevice("/mnt/tmp/hlog/hlog.log");

log = new FasterLog(new FasterLogSettings { LogDevice = device });

using (iter = log.Scan(log.BeginAddress, long.MaxValue))
Expand Down Expand Up @@ -150,15 +157,15 @@ static void ScanThread()

while (true)
{
while (!iter.GetNext(out result, out int length, out _))
while (!iter.GetNext(out result, out _, out _))
{
// For finite end address, check if iteration ended
// if (iter.CurrentAddress >= endAddress) return;
iter.WaitAsync().GetAwaiter().GetResult();
}

// Memory pool variant:
// iter.GetNext(pool, out IMemoryOwner<byte> resultMem, out int length))
// iter.GetNext(pool, out IMemoryOwner<byte> resultMem, out int length, out long currentAddress)

if (Different(result, staticEntry))
throw new Exception("Invalid entry found");
Expand Down
Loading

0 comments on commit ff51d3c

Please sign in to comment.