Skip to content

RATIS-2611. Clear pending queue on all install-snapshot replies#1524

Closed
spacemonkd wants to merge 1 commit into
apache:masterfrom
spacemonkd:RATIS-2611
Closed

RATIS-2611. Clear pending queue on all install-snapshot replies#1524
spacemonkd wants to merge 1 commit into
apache:masterfrom
spacemonkd:RATIS-2611

Conversation

@spacemonkd

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

RATIS-2611. Clear pending queue on all install-snapshot replies

When calling the onNext method, in the various result cases here some cases do not call removePending().

NOT_LEADER
CONF_MISMATCH
UNRECOGNIZED
SNAPSHOT_EXPIRED
these cases do not clear the pending queue and this may possibly fail on the Preconditions.assertSame() check.

pending.poll() removes the oldest enqueued request index. The handler assumes that for each reply we will have one addPending() and then one removePending() call in order.

So if we take an example of chunk install with SNAPSHOT_EXPIRED

  1. Let us assume we send chunk [0,1,2] -> three addPending() calls -> pending queue [0, 1, 2]
  2. Reply with chunk 0 as success -> one removePending() call -> pending.poll() returns 0, condition passed
  3. Reply with chunk 1 as SNAPSHOT_EXPIRED -> pending queue still has [1, 2]

This edge case is handled in the PR.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-2611

How was this patch tested?

Unit tests

@spacemonkd

Copy link
Copy Markdown
Contributor Author

@szetszwo could you take a look at this PR?

P.S. The tests have been generated via Cursor and have been validated locally.

@spacemonkd spacemonkd closed this Jul 21, 2026
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.

1 participant