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 lock expire fail #31166

Closed
ohroy opened this issue Jan 18, 2020 · 2 comments
Closed

redis lock expire fail #31166

ohroy opened this issue Jan 18, 2020 · 2 comments
Labels

Comments

@ohroy
Copy link

ohroy commented Jan 18, 2020

  • Laravel Version: 6.0.0
  • PHP Version: 7.4.0
  • Database Driver & Version:Redis 5

Description:

now logic to acquire a redis lock need 2 steps.
setnx and set expire .
I meet a bug that setnx is sucessed but set expire not. this may cause by network or other weird reasons, but I think this can fix by atomic operation
I fount a pr but it have't be accept, #29076

Steps To Reproduce:

1.breakpoint in

$this->redis->expire($this->name, $this->seconds);

2. try to acquire a redislock
3. wait the breakpoint fire, stop the redis server
4.resume the breakpoint and return
5. restore the redis server

then you will get a never expires lock...
Although the probability of its occurrence is very low, once it occurs, it will cause very serious consequences. In a real business scenario, I have been experiencing this problem recently. Just now I finally discovered the source of the problem.
I hope to be able to fix it.
Thank you.

@ChanJuiHuang
Copy link
Contributor

ChanJuiHuang commented Jan 19, 2020

Hi, Laravel.
Could you reopen this PR #29076 ?
I send this PR in advance!

@driesvints
Copy link
Member

Should be fixed in the next release.

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

3 participants