bugfix: wrap cluster key prefix in a Redis hash tag - #337
Open
DSeaStar wants to merge 1 commit into
Open
Conversation
Saving an entry pipelines the entry hash and the schedule ZSET.
Without a shared hash tag those keys land in different slots and
Redis Cluster raises CROSSSLOT. Wrap an untagged prefix in {…}
only when cluster mode is detected; standalone Redis is unchanged.
fixes sibson#296
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Saving a schedule entry writes the entry hash (
prefix + name) and the schedule ZSET (prefix + ':schedule') in one RedisMULTI. On Redis Cluster those keys hash to different slots unless they share a hash tag, which is the CROSSSLOT failure in #296.When cluster mode is detected (
redis-cluster://orredbeat_redis_options['cluster'] = True) and the prefix has no{…}tag, wrap it so both keys land in the same slot. A user-supplied tag is left alone. Standalone Redis and Sentinel are not rewritten.Also notes the requirement in the cluster docs, and corrects the documented default prefix to
redbeat:(matching the code).Test plan
python -m unittest discover tests(97 passed, 2 skipped)flake8 redbeat testsentry.save()redbeat:keysfixes #296