Skip to content

Occasionally receiving the wrong record from Redis #1818

Closed

Description

@FryJay

Expected behaviour

The correct record is retrieved from Redis

Actual behaviour

On some occasions at sufficient scale (9-10k requests per second), the wrong record is being retrieved from Redis. This issue first appeared when we updated our phpredis driver from 5.0.2 to 5.1.1 (we've since updated to 5.2.2). We have had no luck reproducing the issue outside of our production environment so we believe it to only happen at a sufficient scale that our non-production environments cannot reproduce.

I'm seeing this behaviour on

  • OS: CentOS 7
  • Redis: AWS ElastiCache with Clustered Redis engine 4.0.10
  • PHP: 7.4
  • phpredis: 5.2.2

Steps to reproduce, backtrace or example script

We have had no luck as of yet reproducing the issue outside of our production environment.

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch

Activity

  1. FryJay commented on Jul 27, 2020

    @FryJay
    Author

    Other information that might be relevant:

    • We use persistent connections
    • We had seen the issue once before when upgrading to a 4.x version of the driver and it went away when updated to 5.0.2. I'm trying to track down what specific versions we were using in the first upgrade that went from working to not working.
  2. miksir commented on Aug 21, 2020

    @miksir

    Same issue.
    Redis 5.3.1 Php 7.2.33, pconnect used

    We got issue #1757 and we have added password to options for fix it. Right after that we got same troubles.

  3. yatsukhnenko commented on Aug 21, 2020

    @yatsukhnenko
    Member

    @miksir you can try to set auth parameter in pconnect and not using separated auth method?

  4. miksir commented on Aug 21, 2020

    @miksir

    @yatsukhnenko
    Two days ago we moved auth parameter to pconnect (['auth' => $password]) and removed auth command. Because of AUTH bug.

    After this release we started to receive complains from our devs about "redis returns not that we set". This issue was confirmed - sometimes GET returns garbage (probably values of other keys). This release was reverted and our SRE investigating it now.

  5. yatsukhnenko commented on Aug 21, 2020

    @yatsukhnenko
    Member

    @miksir Have you disabled redis.pconnect.echo_check_liveness in your ini settings?

  6. miksir commented on Aug 21, 2020

    @miksir

    redis.pconnect.echo_check_liveness enabled

    We will try echo_check_liveness, probably it can help to us even with auth command because we have reconnection logic in php. Thanks

  7. miksir commented on Aug 21, 2020

    @miksir

    @yatsukhnenko just checked - we don't use pooling_enabled, so echo_check_liveness shouldn't have an effect

  8. yatsukhnenko commented on Aug 21, 2020

    @yatsukhnenko
    Member

    @miksir then you should use pooling_enabled. It was made to fix issues like yours 😄

  9. yatsukhnenko commented on Aug 28, 2020

    @yatsukhnenko
    Member

    @FryJay @miksir did you try to turn on pooling_enabled and echo_check_liveness INI options?

  10. miksir commented on Sep 18, 2020

    @miksir

    Sorry for delay, currently we can't turn on pooling_enabled because all out team busy moving to redis cluster and did not use persist :) Is pooling_enabled affects connections to cluster too?

  11. Novynn commented on Feb 16, 2021

    @Novynn
    Contributor

    We had the same issue with an older version of PHP Redis using FPMs in a production environment. Upgrading to 5.3.2 with redis.pconnect.echo_check_liveness and redis.pconnect.pooling_enabled as their defaults (enabled) seems to have fixed the problem.

  12. ebogdanov commented on Mar 22, 2021

    @ebogdanov

    We're facing same issue, and it happens when requests to Redis cluster is increasing.
    I.e. we've stable situation (by Grafana's charts), but if we've peak - we can receive wrong data from client.

    PHP 7.2.33-1+ubuntu20.04.1+deb.sury.org+1
    
    redis.pconnect.echo_check_liveness => 1 => 1
    redis.pconnect.pooling_enabled => 1 => 1
    
    
    • persistent option in RedisCluster constructor is set to true

    But if I disable read from slaves in any manner (with RedisCluster::FAILOVER_NONE) problem gones away and never happens.

    Problem is that our current setup is limited in budget and we can't allow interaction with masters only, so that we do balancing with read from slaves.

    I can't find issue just in code :( If you're too busy to lookup, can you point me how to create local developer enviorionment, please?

    So that I will try to debug code step by step, to get idea of it's workflow.

    Thanks in advance.

  13. ebogdanov commented on Apr 1, 2021

    @ebogdanov

    Well, I've found the cause of the issue.
    It is "redis.clusters.cache_slots" option. If it set to 1, then liveness checks are not performed at all.

    @michael-grunder Can you confirm that this is by design, please?

  14. michael-grunder commented on Oct 31, 2025

    @michael-grunder
    Member

    Sorry for such a long delay but I'm going through old issues.

    No, we should continue to do the liveness check even if caching slots. The slot cache and liveness check are two independent parts of the code.

    I just tested this and it works as expected locally.

    I'll close the issue since it's now so old but if anyone is still having this problem, feel free to reopen or comment and I will try to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions