Skip to content

Commit f2a6f0c

Browse files
committed
Ensure memory order
1 parent fd65f6c commit f2a6f0c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cluster/DotNext.Net.Cluster/Net/Cluster/Consensus/Raft/StateMachine/WriteAheadLog.Applier.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ private async Task ApplyAsync(CancellationToken token)
5454
public long LastAppliedIndex
5555
{
5656
get => Volatile.Read(in appliedIndex);
57-
[MethodImpl(MethodImplOptions.NoInlining)]
57+
5858
private set
5959
{
60-
appliedIndex = value;
61-
Interlocked.MemoryBarrier();
60+
// Full memory barrier to ensure that the index cannot be changed later, somewhere
61+
// within Signal due to inlining
62+
Interlocked.Exchange(ref appliedIndex, value);
6263
appliedEvent.Signal(resumeAll: true);
6364
}
6465
}

0 commit comments

Comments
 (0)