Skip to content

KAFKA-10826; Ensure raft io thread respects linger timeout#9716

Merged
hachikuji merged 2 commits into
apache:trunkfrom
hachikuji:KAFKA-10826
Dec 9, 2020
Merged

KAFKA-10826; Ensure raft io thread respects linger timeout#9716
hachikuji merged 2 commits into
apache:trunkfrom
hachikuji:KAFKA-10826

Conversation

@hachikuji

Copy link
Copy Markdown
Contributor

When there are no pending operations, the raft IO thread can block indefinitely waiting for a network event. We rely on asynchronous wakeups in order to break the blocking wait in order to respond to a scheduled append. The current logic already does this, but only for the case when the linger time has been completed during the call to scheduleAppend. It is possible instead that after making one call to scheduleAppend to start the linger timer, the application does not do any additional appends. In this case, we still need the IO thread to wakeup when the linger timer expires. This patch fixes the problem by ensuring that the IO thread gets woken up after the first append which begins the linger timer.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@guozhangwang guozhangwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please feel free to merge afterwards.


public boolean isEmpty() {
// The linger timer begins running when we have pending batches.
// We use this to infer when the accumulator is empty to avoid the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one.

Comment thread raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java Outdated
@hachikuji hachikuji merged commit a8b668b into apache:trunk Dec 9, 2020
@ijuma ijuma added the kraft label Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants