-
Notifications
You must be signed in to change notification settings - Fork 27
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
✨ rabbit_client.subscribe
no longer retries forever if message_handler
always raises unexpected error ⚠️
#5282
✨ rabbit_client.subscribe
no longer retries forever if message_handler
always raises unexpected error ⚠️
#5282
Conversation
rabbit_client.subscribe
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5282 +/- ##
=========================================
+ Coverage 77.9% 87.1% +9.2%
=========================================
Files 1029 1316 +287
Lines 40683 53839 +13156
Branches 765 1173 +408
=========================================
+ Hits 31700 46932 +15232
+ Misses 8833 6657 -2176
- Partials 150 250 +100
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some doubts still on the necessity of this change.
- so if a message is never delivered, we need to look for the exception in graylog right? what about the dead end letter box pattern thingy? did you check that?
- what is the use-case where the handler would constantly fail?
- what is a good number for the failures? and you are saying there is no delay, how will this work?
EDIT:
My use case is the following: I emit messages for some small task, that I know can fail sometimes, due to the state of the system. I want it to actually retry 0 times and give up.
Regarding the no delay: I've seen 1000+ fails in one second on my machine. I think it's a bad idea and could lead to some strange situations or performance going down. Regarding the retry policy, I would put something similar to what tenacity does @pcrespov @sanderegg I have also updated the description of the PR and this is the new design. After the new change. A message will always be retried a set number of times and it is given up if the error keeps raising unexpected errors. NOTE: if the handler returns (False) the message will be send to the original queue, not the one handling the errors. So previous behaviour is unaltered. A WARNING servicelib.rabbitmq._client:_client.py:59 Retry [0/0] for handler '<function test__subscribe_to_failing_message_handler.<locals>._faulty_message_handler at 0x7fdb4b0a9000>', which raised an unexpected error caused by message_id='5b757bf24e734dcdb74940c970646f11' An ERROR servicelib.rabbitmq._client:_client.py:74 Handler '<function test__subscribe_to_failing_message_handler.<locals>._faulty_message_handler at 0x7fdb4b0a9000>' is giving up on message 'IncomingMessage:{'app_id': None,
'body_size': 181,
'cluster_id': '',
'consumer_tag': 'pytest_consumer_neagu-wkst_3113883_pytest_fake_exchange_qaUauvFYAmzYNIRRwotb',
'content_encoding': None,
'content_type': None,
'correlation_id': None,
'delivery_mode': <DeliveryMode.NOT_PERSISTENT: 1>,
'delivery_tag': 1,
'exchange': 'pytest_fake_exchange_qaUauvFYAmzYNIRRwotb',
'expiration': None,
'headers': {},
'message_id': '5b757bf24e734dcdb74940c970646f11',
'priority': 0,
'redelivered': False,
'reply_to': None,
'routing_key': '',
'timestamp': None,
'type': 'None',
'user_id': None}' with body 'b'American whole magazine truth stop whose. On traditional measure example sense peace. Would mouth relate own chair.\nTogether range line beyond. First policy daughter need kind miss.''
Traceback (most recent call last):
File "/home/silenthk/work/pr-osparc-retry-on-error-queue/packages/service-library/src/servicelib/rabbitmq/_client.py", line 54, in _on_message
if not await message_handler(message.body):
File "/home/silenthk/work/pr-osparc-retry-on-error-queue/packages/service-library/tests/rabbitmq/test_rabbitmq.py", line 515, in _faulty_message_handler
raise RuntimeError(msg)
RuntimeError: Always fail. Received message b'American whole magazine truth stop whose. On traditional measure example sense peace. Would mouth relate own chair.\nTogether range line beyond. First policy daughter need kind miss.' |
rabbit_client.subscribe
rabbit_client.subscribe
no longer fails forever if message_handler
is faulty
rabbit_client.subscribe
no longer fails forever if message_handler
is faultyrabbit_client.subscribe
no longer retries forever if message_handler
is faulty
rabbit_client.subscribe
no longer retries forever if message_handler
is faultyrabbit_client.subscribe
no longer retries forever if message_handler
always raises unexpected error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
|
rabbit_client.subscribe
no longer retries forever if message_handler
always raises unexpected errorrabbit_client.subscribe
no longer retries forever if message_handler
always raises unexpected error ⚠️
What do these changes do?
Currently if the
message_handler
raises an exception, the message is queued again to be retried.While this behaviour is useful, in some situations is results being decremental.
Issues with the current design:
message_handler
always raises the message will be retried forever and can overwhelm the systemX
failed attemptsChanges
Added dead letter exchange box
rabbit_client.subscribe
internal queue, which helps to deal with errors.unexpected_error_retry_delay_s
which delays the message by a certain amount before queuing it again in the main queueunexpected_error_max_attempts
which allows to limit how many times themessage_handler
is allowed to raise an error before giving upmessage_handler
returnsFalse
forever, the message will always be queued immediately to the main queue and will be retried as soon as possible (did not change previous behaviour)Related issue/s
How to test
Dev Checklist
DevOps Checklist⚠️
rabbit_cliebt.subscribe
will no longer be able to start. We need to remove the queues (volumes) from rabbitmq in oder for the services to startWhy not have an automatic way to fix this?