Skip to content

Fix WAITAOF reply when using last_offset and last_numreplicas#11917

Merged
oranagra merged 7 commits intoredis:unstablefrom
enjoy-binbin:fix_waitaof_reply
Mar 15, 2023
Merged

Fix WAITAOF reply when using last_offset and last_numreplicas#11917
oranagra merged 7 commits intoredis:unstablefrom
enjoy-binbin:fix_waitaof_reply

Conversation

@enjoy-binbin
Copy link
Contributor

@enjoy-binbin enjoy-binbin commented Mar 15, 2023

WAITAOF wad added in #11713, its return is an array.
But forget to handle WAITAOF in last_offset and last_numreplicas,
causing WAITAOF to return a WAIT like reply.

Tests was added to validate that case (both WAIT and WAITAOF).
This PR also refactored processClientsWaitingReplicas a bit for better
maintainability and readability.

WAITAOF wad added in redis#11713, its return is an array.
But forget to handle WAITAOF in last_offset and last_numreplicas,
causing WAITAOF to return a WAIT like reply.

Tests was added to validate that case (both WAIT and WAITAOF).
@enjoy-binbin
Copy link
Contributor Author

enjoy-binbin commented Mar 15, 2023

the WAIT test case, i will add it later

found it by reviewing the code.

edit: It seems that there is a problem, can WAIT and WAITAOF mix re-use like this?

@enjoy-binbin enjoy-binbin requested a review from oranagra March 15, 2023 05:14
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

thanks for catching my bug in review!!!

@oranagra oranagra merged commit 70b2c4f into redis:unstable Mar 15, 2023
@enjoy-binbin enjoy-binbin deleted the fix_waitaof_reply branch March 15, 2023 09:07
enjoy-binbin added a commit to enjoy-binbin/redis that referenced this pull request Mar 15, 2023
There be a situation that satisfies WAIT, and then wrongly unblock
WAITAOF because we mix-use last_offset and last_numreplicas.

We update last_offset and last_numreplicas only when the condition
matches. i.e. output of either replicationCountAOFAcksByOffset or
replicationCountAcksByOffset is right.

In this case, we need to have separate last_ variables for each of
them. Added a last_aof_offset and last_aof_numreplicas for WAITAOF.

WAITAOF was added in redis#11713. Found while coding redis#11917.
A Test was added to validate that case.
oranagra pushed a commit that referenced this pull request Mar 15, 2023
There be a situation that satisfies WAIT, and then wrongly unblock
WAITAOF because we mix-use last_offset and last_numreplicas.

We update last_offset and last_numreplicas only when the condition
matches. i.e. output of either replicationCountAOFAcksByOffset or
replicationCountAcksByOffset is right.

In this case, we need to have separate last_ variables for each of
them. Added a last_aof_offset and last_aof_numreplicas for WAITAOF.

WAITAOF was added in #11713. Found while coding #11917.
A Test was added to validate that case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants