KAFKA-15648 Update leader volatile before handleLeaderChange in LocalLogManager (#17118)

Update the leader before calling handleLeaderChange and use the given epoch in LocalLogManager#prepareAppend. This should hopefully fix several flaky QuorumControllerTest tests.

Reviewers: José Armando García Sancio <jsancio@apache.org>
This commit is contained in:
David Arthur 2024-09-06 13:54:03 -04:00 committed by GitHub
parent eec9eccacb
commit 1fd1646eb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -563,10 +563,10 @@ public final class LocalLogManager implements RaftClient<ApiMessageAndVersion>,
if (batch.newLeader.equals(sharedLeader)) {
log.debug("Node {}: Executing handleLeaderChange {}",
nodeId, sharedLeader);
listenerData.handleLeaderChange(entryOffset, batch.newLeader);
if (batch.newLeader.epoch() > leader.epoch()) {
leader = batch.newLeader;
}
listenerData.handleLeaderChange(entryOffset, batch.newLeader);
} else {
log.debug("Node {}: Ignoring {} since it doesn't match the latest known leader {}",
nodeId, batch.newLeader, sharedLeader);
@ -733,7 +733,7 @@ public final class LocalLogManager implements RaftClient<ApiMessageAndVersion>,
throw new BufferAllocationException("Test asked to fail the next prepareAppend");
}
return shared.tryAppend(nodeId, leader.epoch(), batch);
return shared.tryAppend(nodeId, epoch, batch);
}
@Override