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

cherry-pick ef2af62 #32643

Conversation

bogdanvlviv
Copy link
Contributor

Fixes #32610. Closes #32614.

Lua scripts in redis are blocking, meaning that no other client can
execute any commands while the script is running. See
https://redis.io/commands/eval#atomicity-of-scripts.

This results in the following exceptions once the number of keys is
sufficiently large:

BUSY Redis is busy running a script.
You can only call SCRIPT KILL or SHUTDOWN NOSAVE.

This commit replaces the lua-based implementation with one that uses
SCAN and DEL in batches. This doesn't block the server.

The primary limitation of SCAN, i.e. potential duplicate keys, is of
no consequence here, because DEL ignores keys that do not exist.

cherry-pick ef2af62

r? @jeremy

Fixes rails#32610. Closes rails#32614.

Lua scripts in redis are *blocking*, meaning that no other client can
execute any commands while the script is running. See
https://redis.io/commands/eval#atomicity-of-scripts.

This results in the following exceptions once the number of keys is
sufficiently large:

    BUSY Redis is busy running a script.
    You can only call SCRIPT KILL or SHUTDOWN NOSAVE.

This commit replaces the lua-based implementation with one that uses
`SCAN` and `DEL` in batches. This doesn't block the server.

The primary limitation of `SCAN`, i.e. potential duplicate keys, is of
no consequence here, because `DEL` ignores keys that do not exist.

cherry-pick ef2af62
@rails-bot
Copy link

warning Warning warning

  • Pull requests are usually filed against the master branch for this repo, but this one is against 5-2-stable. Please double check that you specified the right target!

@rafaelfranca rafaelfranca merged commit 881554b into rails:5-2-stable Apr 19, 2018
@bogdanvlviv bogdanvlviv deleted the cherry-pick-ef2af628a9ec1cc4e7b6997a021dd3f85cfe4665 branch April 19, 2018 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants