Skip to content

bugfix: wrap cluster key prefix in a Redis hash tag - #337

Open
DSeaStar wants to merge 1 commit into
sibson:mainfrom
DSeaStar:fix/cluster-hash-tag-prefix
Open

bugfix: wrap cluster key prefix in a Redis hash tag#337
DSeaStar wants to merge 1 commit into
sibson:mainfrom
DSeaStar:fix/cluster-hash-tag-prefix

Conversation

@DSeaStar

Copy link
Copy Markdown

Summary

Saving a schedule entry writes the entry hash (prefix + name) and the schedule ZSET (prefix + ':schedule') in one Redis MULTI. 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:// or redbeat_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 tests
  • Confirm a cluster install with an untagged prefix no longer raises CROSSSLOT on entry.save()
  • Confirm a standalone Redis install still uses redbeat: keys

fixes #296

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
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.

Error ClusterCrossSlotError

1 participant