WaitForCommitAsync in write operations #25
-
I'm trying to implement my own "reliable queue" on top of your implementation of the Raft protocol. But I don't fully understand how My second question is about how var commitIndex = GetLastIndex(true);
await AppendAsync(new Int64LogEntry { Content = value, Term = Term }, token);
await WaitForCommitAsync(commitIndex + 1L, timeout, token); Is this only for the sake of simplicity? My understanding is that it would be better to wait on the index that is returned by var entryIndex = await AppendAsync(new Int64LogEntry { Content = value, Term = Term }, token);
await WaitForCommitAsync(entryIndex, timeout, token); |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
After thinking this through a bit more I guess the described behavior of |
Beta Was this translation helpful? Give feedback.
-
If
|
Beta Was this translation helpful? Give feedback.
-
The selected ValueTask<long> AppendAsync<TEntryImpl>(ILogEntryProducer<TEntryImpl> entries, CancellationToken token = default(CancellationToken)) This method returns exactly what you want. |
Beta Was this translation helpful? Give feedback.
WaitForCommitAsync
doesn't provide transactional behavior. It's low-level API. Transactional behavior is out of scope of this Raft implementation. It's responsibility of the developer. The method allows you to ensure that the log entry at the specified index is marked as committed by the majority of nodes. It means that the cluster accepts the log record in a consistent way and it cannot be removed from the log. Before that, the log entry has uncommitted state which means that the only local node has this record in the log but all other nodes not. Committing is a process of replication (distribution) of uncommitted log entries by the leader across followers.If
WaitForCommitAsync
is timed…