Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis WAIT commands being applied in MULTI transaction without checking number of replicas #394

Open
ivard opened this issue Dec 13, 2024 · 1 comment
Labels

Comments

@ivard
Copy link
Member

ivard commented Dec 13, 2024

In the Redis documentation the following remark is stated:

If the command is sent as part of a MULTI transaction (since Redis 7.0, any context that does not allow blocking, such as inside scripts), the command does not block but instead just return ASAP the number of replicas that acknowledged the previous write commands.

We currently do this in an attempt to implement a best-effort approach for consistency in Sentinel setups. This can be found in the Redis documentation. If the command does not block in MULTI until the write is acknowledged by two replicas, then the WAIT has little effect. Therefore, we should consider checking the number of replicas the WAIT command returns and implement an alternative flow if the number is less than 2.

If this change is considered to have a too small effect, then the WAIT commands might be superfluous at all.

Examples of places where the WAIT command is called:

if err := s.client.Wait(ctx, 1, time.Second).Err(); err != nil {

if err := tx.Wait(ctx, 1, time.Second).Err(); err != nil {

if err := tx.Wait(ctx, 1, time.Second).Err(); err != nil {

if err := tx.Wait(ctx, 1, time.Second).Err(); err != nil {

@ivard ivard added the bug label Dec 13, 2024
@DibranMulder
Copy link

What should we do other then raising an error? I suggest we log the amount of acknowledged replicas and inspect the behavior. If the systems behaves as expected we might raise an error in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants