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

Bug: Results-middleware doesn't handle ActorNotFound correctly #336

Closed
AndreCimander opened this issue Aug 30, 2020 · 1 comment
Closed
Labels
Milestone

Comments

@AndreCimander
Copy link
Sponsor Contributor

AndreCimander commented Aug 30, 2020

What OS are you using?

Arch Linux

What version of Dramatiq are you using?

1.9.0

What did you do?

Adding a missing-actor message to simulate a staged deployment where events still reference old task names.

What did you expect would happen?

I expected one handled exception (ActorNotFound) with a follow-up action where the message is moved to the DLQ, not a [CRITICAL] Unexpected failure in after_nack. due to the result middleware.

What happened?

[ERROR] Received message for undefined actor ''. Moving it to the DLQ.
python_worker_1      | Traceback (most recent call last):
python_worker_1      |   File "/usr/local/lib/python3.8/site-packages/dramatiq/worker.py", line 314, in handle_message
python_worker_1      |     actor = self.broker.get_actor(message.actor_name)
python_worker_1      |   File "/usr/local/lib/python3.8/site-packages/dramatiq/broker.py", line 214, in get_actor
python_worker_1      |     raise ActorNotFound(actor_name) from None
python_worker_1      | dramatiq.errors.ActorNotFound: ''
python_worker_1      | [2020-08-30 16:24:37,067] [PID 20] [Thread-2] [dramatiq.broker.ExchangeSupportedRabbitmqBroker] [CRITICAL] Unexpected failure in after_nack.
python_worker_1      | Traceback (most recent call last):
python_worker_1      |   File "./utils/dramatiq/brokers.py", line 61, in emit_after
python_worker_1      |     middleware_handler(self, *args, **kwargs)
python_worker_1      |   File "/usr/local/lib/python3.8/site-packages/dramatiq/results/middleware.py", line 95, in after_nack
python_worker_1      |     store_results, result_ttl = self._lookup_options(broker, message)
python_worker_1      |   File "/usr/local/lib/python3.8/site-packages/dramatiq/results/middleware.py", line 84, in _lookup_options
python_worker_1      |     actor = broker.get_actor(message.actor_name)
python_worker_1      |   File "/usr/local/lib/python3.8/site-packages/dramatiq/broker.py", line 214, in get_actor
python_worker_1      |     raise ActorNotFound(actor_name) from None
python_worker_1      | dramatiq.errors.ActorNotFound: ''

Solution:

In dramatiq.results.middleware.Results._lookup_options:84 change the actor fetch to handle missing actors:

    def _lookup_options(self, broker, message):
        try:
             actor = broker.get_actor(message.actor_name)
        except ActorNotFound:
             return False, 0

I'll submit a PR in a few minutes :)

@Bogdanp
Copy link
Owner

Bogdanp commented Sep 5, 2020

Thnaks for the fix. This is now in master and will be released in the next few weeks.

@Bogdanp Bogdanp closed this as completed Sep 5, 2020
@Bogdanp Bogdanp added this to the 1.10.0 milestone Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants