Skip to content

RATIS-2547. Advance repliedIndex before completing write replies#1474

Merged
szetszwo merged 1 commit into
apache:masterfrom
CRZbulabula:ratis-2547
May 29, 2026
Merged

RATIS-2547. Advance repliedIndex before completing write replies#1474
szetszwo merged 1 commit into
apache:masterfrom
CRZbulabula:ratis-2547

Conversation

@CRZbulabula
Copy link
Copy Markdown
Contributor

@CRZbulabula CRZbulabula commented May 29, 2026

RATIS-2547

What changes were proposed in this pull request?

When raft.server.read.option uses REPLIED_INDEX, ReplyFlusher holds write reply callbacks and advances the leader replied index in batches. The old flow invoked reply callbacks while computing the max flushed log index, so a client could receive a successful write reply before repliedIndex covered that write.

This PR stores the log index separately from the reply callback, advances repliedIndex first, and only then completes the held write replies. It also makes LeaderTracer.removePendingRequest tolerate a null pending request for cached-reply paths.

Why are the changes needed?

A read-after-write workload can issue a linearizable read immediately after receiving a successful write reply. With REPLIED_INDEX, that read depends on the leader replied index. Completing the write reply before advancing repliedIndex creates a race where the read can wait unnecessarily or time out even though the write reply was already released.

How was this patch tested?

mvn -pl ratis-server,ratis-test -am -Dtest=TestReplyFlusher,TestLinearizableReadRepliedIndexWithGrpc test

Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@szetszwo szetszwo merged commit f19aecd into apache:master May 29, 2026
32 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants