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] Fix Doctrine setup when using a migration#40055

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
fabpot merged 1 commit intosymfony:5.2fromfabpot:messenger-table-setup-fix
Feb 1, 2021

Conversation

@fabpot
Copy link
Member

QA
Branch?5.2
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#39928
LicenseMIT
Doc PRn/a

#38136 fixed runningmessenger:setup-transports (issue reported in#37179), but it breaks usage withmake:migration (reported in#39928) as code is already executed in a transaction.

This PR fixes both use cases.

@burned42
Copy link
Contributor

Unfortunately this brokemessenger:setup-transports again for me after updating to 5.2.3 with exactly the same error message like in the linked issues.

massimilianobraglia, alexdruhet, and fbourigault reacted with thumbs up emoji

@alexdruhet
Copy link

Also unfortunately, since upgrading to 5.2.3 it's possible that this also brokedoctrine:schema:create, I'm investigating from the message:

No active sql transaction: 7 ERROR: LOCK TABLE can only be used in transaction blocks' while executing DDL: LOCK TABLE messenger_messages;

massimilianobraglia and fabienCambournac reacted with thumbs up emoji

@Nyholm
Copy link
Member

The Messenger component have an event listener (Symfony\Bridge\Doctrine\SchemaListener\MessengerTransportDoctrineSchemaSubscriber) that listens to "onSchemaCreateTable".
That event is fired when one executedoctrine:schema:create (and plenty of more situations). The event listener asksPostgressSqlConnection::getExtraSetupSqlForTable() for SQL to be executed. Since that SQL includes aLOCK TABLE, the SQL needs to be in a transaction.

The commanddoctrine:schema:create does not wrapp things in a transaction, hence, we needBEGIN in the SQL fromPostgressSqlConnection::getExtraSetupSqlForTable().


From my testing with Postgress 11 and Postgress 13. It is fine to haveBEGIN andCOMMIT in a db migration. I don't experience this issues reported in#39928.

I've tested withAbstractMigration::isTransactional() to be true and false.

@Nyholm
Copy link
Member

From my testing with Postgress 11 and Postgress 13. It is fine to have BEGIN and COMMIT in a db migration. I don't experience this issues reported in#39928.

The bug is only present in PHP 8. I was testing with PHP 7

fabpot added a commit that referenced this pull requestMar 4, 2021
This PR was squashed before being merged into the 5.2 branch.Discussion----------[Messenger] Doctrine setup with migrations| Q             | A| ------------- | ---| Branch?       | 5.2| Bug fix?      | yes| New feature?  || Deprecations? | no| Tickets       |Fix#40130| License       | MIT| Doc PR        |This PR reverts parts of#40055.When running these commands, You do need to be in a transaction:- `doctrine:schema:create`- `messenger:setup-transports`- `doctrine:migrations:diff` and `doctrine:migrations:migrate`Commits-------3371e1c [Messenger] Doctrine setup with migrations
fabpot added a commit that referenced this pull requestMar 5, 2021
This PR was merged into the 5.2 branch.Discussion----------[Messenger] Don't lock tables or start transactions| Q             | A| ------------- | ---| Branch?       | 5.2| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       || License       | MIT| Doc PR        |I was so sure my PR#40336 fixed the doctrine-messenger issue once and for all. But it had a very silent bug..This has been tricky to debug and find because the `PDO` behaves differently in PHP 7.4 compared to PHP 8.| Scenario | Command | Is executed in transaction | Method that calls `PostgreSqlConnection::getTriggerSql()` || --| -- | -- | -- || A | `messenger:setup-transports` | No | `setup()`| B| `doctrine:schema:create` | No | `getExtraSetupSqlForTable()`| C | `doctrine:migration:diff` | Yes by default, but it can be configured | `getExtraSetupSqlForTable()`PR#40055 fixed scenario C on PHP 8, but that also broke scenario B on PHP 7.4 and PHP 8.In PR#40336 I was wrong claiming:> We don't need COMMIT because the transaction will commit itself when we close the connection.The result was the we removed all the errors messages from the 3 scenarios. But scenario B will produce some SQL that is actually never committed. IE it will silently fail.I've been trying to figure out a good solution to how or when to start a transaction. I tried out@fbourigault [suggestion](#40336 (comment)) but that would be the same fix as#40055.---------------We need a transaction because the SQL includes a `LOCK TABLE`, however, I cannot see a strict need for it. This PR removes `LOCK TABLE` and all transaction juggling. It all seams to work.I would be happy to get thorough feedback on this PR so we can end the chapter of constantly adding bugs to this part of the component.@dunglas, you added `LOCK TABLE` in your initial version of this class in#35485, could you share some knowledge if this is a good or bad idea?Commits-------26061a1 Dont lock tables or start transactions
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@srozesrozeAwaiting requested review from sroze

Assignees

No one assigned

Projects

None yet

Milestone

5.2

Development

Successfully merging this pull request may close these issues.

5 participants

@fabpot@burned42@alexdruhet@Nyholm@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp