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

Namespacing not used for RedisBackend results storage #499

Open
7 tasks done
coandco opened this issue Jul 11, 2022 · 0 comments
Open
7 tasks done

Namespacing not used for RedisBackend results storage #499

coandco opened this issue Jul 11, 2022 · 0 comments

Comments

@coandco
Copy link

coandco commented Jul 11, 2022

Issues

GitHub issues are for bugs. If you have questions, please ask them on the discussion board.

Checklist

  • Does your title concisely summarize the problem?
  • Did you include a minimal, reproducible example?
  • What OS are you using?
  • What version of Dramatiq are you using?
  • What did you do?
  • What did you expect would happen?
  • What happened?

What OS are you using?

Ubuntu 20.04

What version of Dramatiq are you using?

1.13.0

What did you do?

I'm investigating dramatiq for my project, and I set it up like so:

redis_nodes = {'localhost': 6379}
redis_client = Redis(host='localhost', port=6379)
broker = RedisBroker(client=redis_client, namespace="{dramatiq}")
broker.add_middleware(Results(backend=RedisBackend(client=redis_client, namespace="{dramatiq}:results")))
dramatiq.set_broker(broker)

What did you expect would happen?

I expected that message results would get stored in a namespaced key in Redis -- that is to say, that the message results would be something like {dramatiq}:results:<message-id>.

What happened?

The results got stored without the namespace. Looking at the code, it creates a nice namespaced string in the form of %(namespace)s:%(queue_name)s:%(actor_name)s:%(message_id)s at https://github.com/Bogdanp/dramatiq/blob/master/dramatiq/results/backend.py#L146, then tosses that all away and takes the md5 hash at https://github.com/Bogdanp/dramatiq/blob/master/dramatiq/results/backend.py#L152. This results in non-namespaced md5 hashes getting written to the Redis server, which could lead to md5 collisions with other non-namespaced services using the same server. Also, this prevents results from being used with a Redis hash tag in the event the upstream server is a Redis Cluster.

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

No branches or pull requests

1 participant