-
Notifications
You must be signed in to change notification settings - Fork 570
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#] FasterLog - tailing iterator from different process #332
Comments
Sure, that should be doable, you just need to recover from the second process and perform the iteration there. To refresh the latest updates, you would need to "recover" again to the latest commit. |
That is ideal! I needed to be able to progressively read from the log and was hoping for something like this. Just to be clear, I'm assuming that truncating or writing from the 2nd process is not supported, correct? |
To be clear, the basic underlying capability is there but is not exposed or supported out of the box right now. I tried to play around and it works but will need some effort to convert into a supported feature. Work in branch: fasterlog-separate-scan |
That is correct. The reader gets a read-only view of the log. |
Marking this as feature request/enhancement based on this work. |
It's now in relatively stable state - but still in branch. Feel free to play with the sample to see if that is what you had in mind. Log truncation right now needs to be handled by the primary owner (writer), as it is the point of truth for the log. The way we expose the reading capability in the second process is summarized in the code snippet below: static async Task SeparateConsumerAsync(CancellationToken cancellationToken)
{
var device = Devices.CreateLogDevice(path + "mylog");
var log = new FasterLog(new FasterLogSettings { LogDevice = device, ReadOnlyMode = true, PageSizeBits = 9, SegmentSizeBits = 9 });
var _ = RecoverAsync(log, cancellationToken);
using var iter = log.Scan(log.BeginAddress, long.MaxValue);
await foreach (var (result, length, currentAddress, nextAddress) in iter.GetAsyncEnumerable(cancellationToken))
{
Console.WriteLine($"Consuming {Encoding.UTF8.GetString(result)}");
iter.CompleteUntil(nextAddress);
}
}
static async Task RecoverAsync(FasterLog log, CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
await Task.Delay(TimeSpan.FromMilliseconds(restorePeriodMs), cancellationToken);
Console.WriteLine("Restoring ...");
log.RecoverReadOnly();
}
} |
Goodness you are fast 🤯 I'm looking forward to seeing saturating my disk IO testing this out! |
The linked sample will probably have overheads due to string encoding and decoding. Using byte arrays or spans as in this sample is best for perf/benchmarking. |
Can FasterLog be used by multiple processes in any configuration?
My primary use case would be a single Writer Process and a single Reader Process.
I'm ok with the reader being truly read-only and not being able to truncate.
The text was updated successfully, but these errors were encountered: