From b4e4803b42d02f8c7017a492ad7a23eeea4b478c Mon Sep 17 00:00:00 2001 From: Tianyu Li Date: Mon, 12 Sep 2022 14:42:57 +0000 Subject: [PATCH] Fix epoch refresh of uncommitted safe tail --- cs/src/core/FasterLog/FasterLog.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cs/src/core/FasterLog/FasterLog.cs b/cs/src/core/FasterLog/FasterLog.cs index 30f07ba21..1d6dbe56c 100644 --- a/cs/src/core/FasterLog/FasterLog.cs +++ b/cs/src/core/FasterLog/FasterLog.cs @@ -1521,18 +1521,20 @@ private void EpochProtectAutoRefreshSafeTailAddressRunner() private void AutoRefreshSafeTailAddressRunner(bool recurse) { + long tail = 0; do { - if (TailAddress > SafeTailAddress) + tail = TailAddress; + if (tail > SafeTailAddress) { if (recurse) Task.Run(EpochProtectAutoRefreshSafeTailAddressRunner); else - epoch.BumpCurrentEpoch(() => AutoRefreshSafeTailAddressBumpCallback(TailAddress)); + epoch.BumpCurrentEpoch(() => AutoRefreshSafeTailAddressBumpCallback(tail)); return; } _ongoingAutoRefreshSafeTailAddress = 0; - } while (TailAddress > SafeTailAddress && _ongoingAutoRefreshSafeTailAddress == 0 && Interlocked.CompareExchange(ref _ongoingAutoRefreshSafeTailAddress, 1, 0) == 0); + } while (tail > SafeTailAddress && _ongoingAutoRefreshSafeTailAddress == 0 && Interlocked.CompareExchange(ref _ongoingAutoRefreshSafeTailAddress, 1, 0) == 0); } private void AutoRefreshSafeTailAddressBumpCallback(long tailAddress)