-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Skipped messages can get inconsistent results stored #440
Comments
If an approach can be agreed upon, I would be happy to submit a PR to fix it. It seems like the Age Limit middleware should at least be raising SkipMessage(), to trigger any |
Maybe |
Ok, what about raising Lines 495 to 504 in fa732f4
If that sounds good, I can submit a PR for this. |
Yes, I think that would be fine. |
Fixes Bogdanp#440 Stuff SkipMessage exceptions into the message proxy to ensure that the result is consistent when used in conjunction with the Results middleware. Additionally, move the message.fail() call into the SkipMessage handling to ensure that skipped messages are nack'd rather than ack'd. Note that if failing the message is left to the middleware, then unintentionally omitting message.fail() can lead to no result ever being stored by the results middleware for the message. If it should be left to the middleware to decide to fail the skipped message then it would be more sensible to have fail as the default. This could be achieved by making the SkipMessage exception take an optional "fail_message" parameter that defaults to True, and have the message conditionally fail() inside the worker SkipMessage exception handling. Custom middleware could then raise SkipMessage with fail_message=False to override this behaviour and lead to the message being skipped and ack'd rather than skipped and nack'd.
Hey @FinnLidbetter, I took a look at it a while back, but I need to think about it some more because it might not be the right approach after all. I'll try to find some time to look at it again this weekend or the next. |
Ok no problem, that sounds good to me, thank you. Let me know if there's anything I can do to help. |
If a message is dropped because of the Age Limit middleware, then getting the result of that message will be inconsistent depending on how soon after the message is dropped an attempt to get the result is made.
Not sure what the resolution should be here. I think it should either consistently store a None result, or consistently store an exception that is not
Exception("unknown")
.What OS are you using?
Ubuntu 20.04
What version of Dramatiq are you using?
1.11.0
What did you do?
Use a broker with the AgeLimit and Results middleware. Have a message hit its age limit and get its result in a blocking get_result call. Get the result for the same message again a second or two after the blocking get_result returns a result.
What did you expect would happen?
The result should not change.
What happened?
On the first get_result, the result is None.
On the second get_result, retrieving the result raises a ResultFailure exception with exception
Exception("unknown")
This appears to be because:
failed
flag on the MessageProxy before the message is processeddramatiq/dramatiq/middleware/age_limit.py
Lines 41 to 50 in e1f3245
dramatiq/dramatiq/worker.py
Line 493 in e1f3245
after_process_message
will then store this None result and no exceptiondramatiq/dramatiq/results/middleware.py
Line 95 in e1f3245
emit_after
of "nack"dramatiq/dramatiq/worker.py
Line 347 in e1f3245
dramatiq/dramatiq/results/middleware.py
Lines 105 to 109 in e1f3245
Sample Code
The text was updated successfully, but these errors were encountered: