Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Add a middleware to log when transaction has been left open#41265

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chalasr merged 1 commit intosymfony:5.4fromlyrixx:messenger-transation-watchdog
Oct 5, 2021

Conversation

@lyrixx
Copy link
Member

@lyrixxlyrixx commentedMay 18, 2021
edited
Loading

QA
Branch?5.4
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PR

I notice something that can hurt applications: If one open a transaction
in a handler, but don't close it, the transaction is not close by
Doctrine nor Symfony. So all others messages are still handled in the
transaction. More over, when the retry limit is reach, messenger will
try to save the message in the failed transport. In my case it's
doctrine. So the failed message is save, but inner a transaction. When
the worker stop, the transaction is rollbacked, and so the message is
lost.

@lyrixx
Copy link
MemberAuthor

ping @symfony/mergers

@lyrixxlyrixx changed the title[Messenger] Add support for DoctrineTransactionWatchdogMiddleware[Messenger] Add a middleware to ensure all transaction has been closedJul 23, 2021
@lyrixxlyrixxforce-pushed themessenger-transation-watchdog branch frome7db3da tod0dbdd0CompareJuly 23, 2021 16:24
@lyrixx
Copy link
MemberAuthor

@OskarStark Thanks for the review.


I added tests + entry in the CHANGELOG.
It should be OK

OskarStark reacted with heart emoji

@lyrixxlyrixxforce-pushed themessenger-transation-watchdog branch fromd0dbdd0 tobad5019CompareJuly 23, 2021 16:28
@Nyholm
Copy link
Member

Thank you for this PR.

This scenario seams like an edge case. My experience is obviously biased, but I can count the number of times I've been working with DB transactions on my one hand.

Given you have code in your handler that open a transaction, I think that handler should also be responsible to make sure the transaction is closed.

I do see the value for a middleware like this in your application or in a third partly library. But I don't think it should be in the Symfony organisation.

Im 👎

sstok reacted with eyes emoji

@lyrixx
Copy link
MemberAuthor

Don't get me wrong: this middleware is a watchdog. People should not really on it. As you can see, when it's triggered, it generates anerror log.

So yes, all open transaction must to closed in the handler, I agree with you on this point.

@lyrixxlyrixxforce-pushed themessenger-transation-watchdog branch 4 times, most recently from230bede to9929d9cCompareSeptember 1, 2021 17:12
@lyrixx
Copy link
MemberAuthor

lyrixx commentedSep 15, 2021
edited
Loading

People tend to like this feature:https://twitter.com/lyrixx/status/1437440305159094275 andhttps://twitter.com/lyrixx/status/1418497608658661382

Another option would be to throw an exception when the transaction is not finished.

@lyrixx
Copy link
MemberAuthor

Another option would be to throw an exception when the transaction is not finished.

ping@Nyholm ; What do you think ? 👆

@fabpot
Copy link
Member

First sentence of the description says: "This is a WIP to get some feedback." So, I suppose it cannot be merged yet :)

@lyrixx
Copy link
MemberAuthor

@fabpot I have edited the PR description, thanks :)

@chalasr
Copy link
Member

I share Tobias's feeling here, the proposed middleware seems too specific for being in core to me (same for the exception alternative).

@lyrixx
Copy link
MemberAuthor

lyrixx commentedSep 22, 2021
edited
Loading

@chalasr as I explained in the PR description, forgetting to close a transaction can really hurt. IMHO this middleware should be native and not op-tin 😬

I understand your point of view, but as you can see, people on twitter tend to like it 👼🏼

apfelbox reacted with thumbs up emoji

@chalasr
Copy link
Member

chalasr commentedSep 22, 2021
edited
Loading

Well, it's less than your average likes on contrib related tweets isn't it? 🙃

Jokes aside, I can see the potential value for debugging so I won't block this PR.
Could it just log? Or perhaps it could be configurable (log vs exception vs rollback)?

@lyrixx
Copy link
MemberAuthor

I could just log indeed, without exception, and without throwing. I'll update the PR.

@lyrixxlyrixxforce-pushed themessenger-transation-watchdog branch from9929d9c to8a841ceCompareOctober 1, 2021 09:05
@lyrixx
Copy link
MemberAuthor

I updated the PR. now, it only log aterror level when a transaction is open

@OskarStark
Copy link
Contributor

Maybe "Detect" is more appropriate than "watchdog"?

@lyrixxlyrixxforce-pushed themessenger-transation-watchdog branch from8a841ce tod9f31acCompareOctober 4, 2021 15:35
@lyrixx
Copy link
MemberAuthor

I have renamed everything:

Add a middleware to log when transaction has been left openDoctrineOpenTransactionLoggerMiddleware

@lyrixxlyrixx changed the title[Messenger] Add a middleware to ensure all transaction has been closedAdd a middleware to log when transaction has been left openDoctrineOpenTransactionLoggerMiddlewareOct 4, 2021
@lyrixxlyrixx changed the titleAdd a middleware to log when transaction has been left openDoctrineOpenTransactionLoggerMiddleware[Messenger] Add a middleware to log when transaction has been left openOct 4, 2021
@chalasrchalasrforce-pushed themessenger-transation-watchdog branch 2 times, most recently fromf454955 tofaae1a2CompareOctober 5, 2021 14:42
@chalasrchalasrforce-pushed themessenger-transation-watchdog branch fromfaae1a2 to838846aCompareOctober 5, 2021 15:04
@chalasr
Copy link
Member

Thank you@lyrixx.

@chalasrchalasr merged commit2100d7b intosymfony:5.4Oct 5, 2021
@lyrixxlyrixx deleted the messenger-transation-watchdog branchOctober 5, 2021 16:15
This was referencedNov 5, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

@chalasrchalasrchalasr approved these changes

@srozesrozeAwaiting requested review from sroze

@dunglasdunglasAwaiting requested review from dunglas

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@lyrixx@Nyholm@fabpot@chalasr@OskarStark@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp