8000 Revert "[Messenger] Fix exception message of failed message is dropped by Tobion · Pull Request #34082 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Revert "[Messenger] Fix exception message of failed message is dropped #34082

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

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

Tobion
Copy link
Contributor
@Tobion Tobion commented Oct 23, 2019
Q A
Branch? 4.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

This reverts #33600 because it makes the message grow for each retry until AMQP cannot handle it anymore. On each retry, the full exception trace is added to the message. So in our case on the 5th retry, the message is too big for the AMQP library to encode it. AMQP extension then throws the exception

Library error: table too large for buffer

(ref. alanxz/rabbitmq-c#224 and php-amqp/php-amqp#131) when trying to publish the message.

To solve this, I suggest to revert #33600 (this PR) and merge #32341 instead which does not re-add the exception on each failure.

Btw, the above problem causes other problematic side-effects of Symfony messenger. As the new retry message fails to be published with an exception, the old (currently processed message) also does not get removed (acknowledged) from the delay queue. So rabbitmq redelivers the message and the same thing happens forever. This can block the consumers and have a huge toll on your service. That's just another case for #32055 (comment). I'll try to fix this in another PR. Edit: Here it is #34107

@weaverryan
Copy link
Member

Sorry for being late on #33600 stuff!

Summary:

A) We should merge this and revert #33600 (into 4.3)
B) We should merge #32341, which is a superficial fix in how the exception info is displayed in the command (into 4.3)
C) We should consider #32904 for the future, which is a safer way to try to store some exception info for each time it fails. (4.4 or 5.1 - I know 4.4 needs to get shipped)

Tobion added a commit that referenced this pull request Oct 23, 2019
…e is dropped (Tobion)

This PR was merged into the 4.3 branch.

Discussion
----------

Revert "[Messenger] Fix exception message of failed message is dropped

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       |
| License       | MIT
| Doc PR        |

This reverts #33600 because it makes the message grow for each retry until AMQP cannot handle it anymore. On each retry, the full exception trace is added to the message. So in our case on the 5th retry, the message is too big for the AMQP library to encode it. AMQP extension then throws the exception

> Library error: table too large for buffer

(ref. alanxz/rabbitmq-c#224 and php-amqp/php-amqp#131) when trying to publish the message.

To solve this, I suggest to revert #33600 (this PR) and merge #32341 instead which does not re-add the exception on each failure.

Btw, the above problem causes other problematic side-effects of Symfony messenger. As the new retry message fails to be published with an exception, the old (currently processed message) also does not get removed (acknowledged) from the delay queue. So rabbitmq redelivers the message and the same thing happens forever. This can block the consumers and have a huge toll on your service. That's just another case for #32055 (comment). I'll try to fix this in another PR.

Commits
-------

3dbe924 Revert "[Messenger] Fix exception message of failed message is dropped on retry"
@Tobion Tobion merged commit 3dbe924 into symfony:4.3 Oct 23, 2019
@Tobion Tobion deleted the fix-message-size-growing branch October 23, 2019 12:37
@fabpot fabpot mentioned this pull request Nov 1, 2019
@Warxcell
Copy link
Contributor
Warxcell commented Sep 21, 2021

Still got same problem here. I could reproduce it by simply adding following in the handler

        $exception = null;
        for ($i = 0; $i < 10; $i++) {
            $exception = new Exception('Exception', null, $exception);
        }
        throw $exception;

Then I got

In AmqpSender.php line 77:
                                             
  Library error: table too large for buffer  

@yyaremenko
Copy link

@Tobion I can also confirm the bug still exists, can you re-check if it was really fixed please? Also is there a test which validates the bugfix?

symfony/messenger v5.3.10

@yyaremenko
Copy link
yyaremenko commented Jan 12, 2022

Okay, for those who still gets the above error and uses RabbitMQ broker.

In short, the key is message's headers: a type header and stamps headers. If you don't provide or corrupt such headers, you'll get the growing message problem.

This helped me, hopefully this will help you.

  1. Make sure your symfony and messenger bundle are of version >=5.4

  2. If you send 'symfony' ('internal', not 'external') messages manually, by publishing messages via RabbitMQ interface, and consuming such messages in your app, you'll get the problem discussed here - because most probably you won't provide all needed headers. As a workaround, find a way to publish the message via your app (e.g. temporary modify your code) without consuming that message, then go to RabbitMQ UI and see what headers are provided in the message. Use these headers later on when sending messages manually (the main headers you'll probably need would be something like 'type' and 'X-Message-Stamp-Symfony\Component\Messenger\Stamp\BusNameStamp')

  3. For external messages, in case you followed the official symfony instruction here https://symfonycasts.com/screencast/messenger/transport-serializer#codeblock-bca382fd36 - bad news, the instruction is misleading, which is not a big of surprise. If you take a look at how the stamps and 'type' are actually decoded/encoded in Symfony\Component\Messenger\Transport\Serialization\Serializer - you'll be surprised how much it differs from the instruction, especially that there is a type of stamps which must not be sent on retry at all, of a NonSendableStampInterface. So, your custom serializer for external messages must extend from Symfony\Component\Messenger\Transport\Serialization\Serializer as a starting point.

@enumag
Copy link
Contributor
enumag commented Jan 28, 2022

In my case I got this error after an exception with way too long message. It was ServiceNotFoundException which listed all other services in a ServiceLocator instance which was several hundreds class names. This got into ErrorDetailsStamp which ended up way too large.

However I saw the same error once even after fixing that. I think it can grow too large simply from the exception traces in ErrorDetailsStamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0