Skip to content

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

@ivard

Description

@ivard

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 {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions