From fccfbcff8aa1c009be4a66c55595ce4570a4141e Mon Sep 17 00:00:00 2001 From: Masashi Ito <59102452+mito-csod@users.noreply.github.com> Date: Tue, 23 Nov 2021 10:47:02 -0800 Subject: [PATCH] Disable checksum verification in FasterLogIterator.CompleteUntilRecordAt() (#602) * MemoryPool-based override for FasterLog.ReadAsync() * FasterLogIterator.CompleteUntilRecordAtAsync() added. * disable checksum verification in FasterLogIterator.CompleteUntilRecordAt() [#601] Co-authored-by: Badrish Chandramouli --- cs/src/core/Index/FasterLog/FasterLog.cs | 8 ++------ cs/src/core/Index/FasterLog/FasterLogIterator.cs | 7 +++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cs/src/core/Index/FasterLog/FasterLog.cs b/cs/src/core/Index/FasterLog/FasterLog.cs index 99a3536db..d74fa4b72 100644 --- a/cs/src/core/Index/FasterLog/FasterLog.cs +++ b/cs/src/core/Index/FasterLog/FasterLog.cs @@ -900,8 +900,7 @@ public async ValueTask ReadRecordLengthAsync(long address, CancellationToke allocator.AsyncReadRecordToMemory(address, headerSize, AsyncGetHeaderOnlyFromDiskCallback, ref ctx); } epoch.Suspend(); - await ctx.completedRead.WaitAsync(token).ConfigureAwait(false); - + await ctx.completedRead.WaitAsync(token).ConfigureAwait(false); return GetRecordLengthAndFree(ctx.record); } @@ -1320,10 +1319,7 @@ private int GetRecordLengthAndFree(SectorAlignedMemory record) var ptr = record.GetValidPointer(); length = GetLength(ptr); - if (!VerifyChecksum(ptr, length)) - { - throw new FasterException("Checksum failed for read"); - } + // forego checksum verification since record may not be read in full by AsyncGetHeaderOnlyFromDiskCallback() } record.Return(); diff --git a/cs/src/core/Index/FasterLog/FasterLogIterator.cs b/cs/src/core/Index/FasterLog/FasterLogIterator.cs index 77395d25e..1f46467d3 100644 --- a/cs/src/core/Index/FasterLog/FasterLogIterator.cs +++ b/cs/src/core/Index/FasterLog/FasterLogIterator.cs @@ -299,10 +299,13 @@ public void CompleteUntil(long address) /// /// /// - public async ValueTask CompleteUntilRecordAtAsync(long recordStartAddress, CancellationToken token = default) + /// The actual completion address (end address of the record) + public async ValueTask CompleteUntilRecordAtAsync(long recordStartAddress, CancellationToken token = default) { int len = await fasterLog.ReadRecordLengthAsync(recordStartAddress, token: token); - CompleteUntil(recordStartAddress + headerSize + len); + long endAddress = recordStartAddress + headerSize + Align(len); + CompleteUntil(endAddress); + return endAddress; } internal void UpdateCompletedUntilAddress(long address)