Skip to content
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

Raft leader uses the same previous LogEntryIndex and Term to all batched AppendEntries message #123

Closed
xirc opened this issue Jan 18, 2022 · 1 comment · Fixed by #122
Closed
Labels
bug Something isn't working
Milestone

Comments

@xirc
Copy link
Contributor

xirc commented Jan 18, 2022

Leader uses the same previous values (prevLogIndex and prevLogTerm) to all batched AppendEntries messages.

private[this] def publishAppendEntries(): Unit = {
resetHeartbeatTimeoutTimer()
otherMemberIndexes.foreach { memberIndex =>
val nextIndex = currentData.nextIndexFor(memberIndex)
val prevLogIndex = nextIndex.prev()
val prevLogTerm = currentData.replicatedLog.termAt(prevLogIndex)
val messages =
prevLogTerm match {
case Some(prevLogTerm) =>
val batchEntries = currentData.replicatedLog.getFrom(
nextIndex,
settings.maxAppendEntriesSize,
settings.maxAppendEntriesBatchSize,
)
batchEntries match {
case batchEntries if batchEntries.isEmpty =>
Seq(
AppendEntries(
shardId,
currentData.currentTerm,
selfMemberIndex,
prevLogIndex,
prevLogTerm,
entries = Seq.empty,
currentData.commitIndex,
),
)
case batchEntries =>
batchEntries.map { entries =>
AppendEntries(
shardId,
currentData.currentTerm,
selfMemberIndex,
prevLogIndex,
prevLogTerm,
entries,
currentData.commitIndex,
)
}
}

Expected

Raft leader should set appropriate previous values (prevLogIndex and prevLogTerm) to batched AppendEntries. The expected AppendEntries is the following:
upload_4544b9b53e981046efa99e0a25179257

@xirc xirc added this to the v2.1.0 milestone Jan 18, 2022
@xirc xirc added the bug Something isn't working label Jan 18, 2022
@xirc xirc changed the title Raft leader should set appropriate previous values (prevLogIndex and prevLogTerm) to batched AppendEntries Raft leader uses the same previous LogEntryIndex and Term to all batched AppendEntries message Jan 18, 2022
@xirc
Copy link
Contributor Author

xirc commented Jan 20, 2022

Possible workaround:

  • Use lerna.akka.entityreplication.raft.max-append-entries-batch-size = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant