-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mesenger] Add support for reseting container services between 2 messages #41163
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
Conversation
0a51dc6
to
ae3dc21
Compare
This comment has been minimized.
This comment has been minimized.
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
ae3dc21
to
d9b324a
Compare
Hello, I have rebased this PR, and addressed all comments. I should be OK now |
I could rebase this PR, but before doing so, I prefer to be sure it's mergeable. so WDYT? Edit: I have rebased the PR |
d9b324a
to
c52c434
Compare
From my experience, a worker running without processing messages can also go out of memory. For example if you have an app running in debug mode the tracing/profiling will keep event-dispatcher events in memory, eventually causing the process to go out of memory. Because of this, should there also be a possibility to trigger the reset And continuing on that, would it be nice if you could do a reset when the worker is inactive (Can be read |
Indeed, cf #32422
I don't understand :/
Indeed, that would be possible, in a next PR :) |
If I understood the logic in this PR correctly, a reset is only triggered by on of those |
Ohhh, I see, good point. I need to check when the running event is triggered to ensure it does not break something |
I think it should be just as safe as the other events, it at least not during the handling of a message: https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Messenger/Worker.php#L95 |
c52c434
to
f0fbce3
Compare
@Jeroeny Here we go 👍🏼 I pushed a new version where the listener listen |
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.
Can you update the description to explain when and why one should enable or disable this flag? If you can create a PR on the docs, that would be the cherry on the cake :)
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
…ssenger message. Without this patch, services are not resetted. For example Monolog Finger Cross handler is never reset nor flushed. So if the first message trigger and "error" level message, all others message will log and overflow the buffer. Usage with framework: ```yaml framework: messenger: transports: async: dsn: '%env(MESSENGER_TRANSPORT_DSN)%' reset_on_message: true failed: 'doctrine://default?queue_name=failed' sync: 'sync://' ```
f0fbce3
to
488bb88
Compare
@fabpot I haved edited the PR description, and the configuration. |
Thank you @lyrixx. |
@@ -195,6 +196,12 @@ | |||
->tag('kernel.event_subscriber') | |||
|
|||
->set('messenger.listener.stop_worker_on_stop_exception_listener', StopWorkerOnCustomStopExceptionListener::class) | |||
|
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.
Is it correct that the StopWorkerOnCustomStopExceptionListener
service looses the kernel.event_subscriber
tag?
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, fixed in #43002
…rkerOnCustomStopExceptionListener (lyrixx) This PR was merged into the 5.4 branch. Discussion ---------- [Messenger] Add back kernel.event_subscriber tag on StopWorkerOnCustomStopExceptionListener | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes (but the bug was not released) | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | refs: #41163 (comment) Commits ------- 00a34c6 [Messenger] Add back kernel.event_subscriber tag on StopWorkerOnCustomStopExceptionListener
…rkerOnCustomStopExceptionListener (lyrixx) This PR was merged into the 5.4 branch. Discussion ---------- [Messenger] Add back kernel.event_subscriber tag on StopWorkerOnCustomStopExceptionListener | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes (but the bug was not released) | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | refs: symfony/symfony#41163 (comment) Commits ------- 00a34c623b [Messenger] Add back kernel.event_subscriber tag on StopWorkerOnCustomStopExceptionListener
…lyrixx) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Messenger] document reset_on_message transport option refs symfony/symfony#41163 Commits ------- 3f7ebce [Messenger] document reset_on_message transport option
Without this patch, services are not resetted. For example Monolog
Finger Cross handler is never reset nor flushed. So if the first
message trigger and "error" level message, all others message will log
and overflow the buffer.
So, when a transport is async (it means it is run in a worker), it's highly preferable to this configuration on
Usage with framework: