Skip to content

Redis lock with setnx will lead to deadlocks #46

@twisted1919

Description

@twisted1919

Hello,

We used to use the library in one of our applications and we always got deadlocks when under certain load.
Because of the nature of such problems, it was extraordinary difficult to find why this happens, we have changed our code multiple times and never suspected the problem is caused by an underlaying library.

In one of the debug sessions, using strace we could see the process is stuck doing a SETNX command. Reading about the command at https://redis.io/commands/setnx#design-pattern-locking-with-codesetnxcode says it should not be used for this purposes anymore. Digging further to see what piece of code uses this command, we ended up finding https://github.com/arvenil/mutex/blob/master/src/Lock/PredisRedisLock.php#L45

Maybe you should look into it and find a better alternative.
Best.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions