-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Delete returns 0 for a key that exists #816
Comments
Hey, Is it possible that the key is being removed by redis between your call to It's always possible something else is happening, but just wanted to point out that it is theoretically possible for the key to get expired between those two round trips. Mike |
Hey @michael-grunder, I should also mention I usually see this error when I make two concurrent requests. Your analysis seems likely in that situation. What's the proper way to handle this? I could do a delete and an exists where the !$del code is but that feels like the wrong approach. |
Perhaps a MULTI...EXEC block or a small piece of LUA script to make all the requests a single transaction? |
This is part of a framework's session library and I don't think disallowing concurrent requests is the right direction. I'll pass your comments on to one of the developers thanks! |
It shouldn't disable concurrent connections really. Redis is already single-threaded, so when you get right down to it, only one Again, I don't know if that's actually what's causing the problem but it's just a guess! Let me know if you get more info on the problem and I'll be happy to help! |
Oh sorry what I meant by that is concurrent AJAX requests. This is part of a PHP framework and when two simultaneous AJAX calls are sent one of them produces this error. I didn't realize multi was part of Redis, I'll pass that on as well. |
Hi, I'm the developer that this was supposedly relayed to ... only I've been subscribed to this issue the whole time. The It is faulty because (bar Redis just dropping it for no obvious reason) the key in question does certainly exist when As for the expiry possibility - "extremely unlikely" would be an understatement, because the TTL is set to 300 seconds (5 minutes) and so far the issue has only been reproduced while processing concurrent AJAX requests - no such requests taking 5+ minutes to complete would go unnoticed. |
Seeing some really odd results using this extension with CodeIgniter's Redis session library. When close is called I get an error that it cannot free the lock. I'm using the latest release of this extension (2.2.7) and CI (3.0.6) on PHP 5.6.
Here's a link to the library's code: https://github.com/bcit-ci/CodeIgniter/blob/develop/system/libraries/Session/drivers/Session_redis_driver.php
Here's a modified code exert so you can see exactly where the error appears:
The error I get is:
Session: Error while trying to free lock for ci_session:guid:lock, code=2, del=0, exists=true, exists2=false
Is this expected since the key is set to expire? Why does exists return true but delete returns 0 immediately after? The second exists2 returns false as expected.
If this is expected, what is the proper way to delete the key so it returns a non 0 response?
The text was updated successfully, but these errors were encountered: