This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier 9978ba805f bug #40376 [Messenger] Don't lock tables or start transactions (Nyholm)
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](https://github.com/symfony/symfony/pull/40336#issuecomment-790622951) 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 https://github.com/symfony/symfony/pull/35485, could you share some knowledge if this is a good or bad idea?

Commits
-------

26061a131d Dont lock tables or start transactions
2021-03-05 18:19:32 +01:00
.github Merge branch '4.4' into 5.2 2021-03-02 13:14:02 +01:00
src/Symfony bug #40376 [Messenger] Don't lock tables or start transactions (Nyholm) 2021-03-05 18:19:32 +01:00
.appveyor.yml Merge branch '4.4' into 5.2 2021-02-16 11:13:48 +01:00
.editorconfig Update .editorconfig 2018-09-06 16:22:56 +02:00
.gitattributes "export-ignore" contracts and phpunit-bridge 2021-01-22 10:53:35 +01:00
.gitignore Run the phpunit-bridge from a PR 2019-08-02 17:46:19 +02:00
.php_cs.dist Merge branch '5.1' into 5.2 2021-01-19 22:00:40 +01:00
.travis.yml Merge branch '4.4' into 5.2 2021-02-17 16:24:54 +01:00
CHANGELOG-5.0.md Merge branch '5.0' into 5.1 2020-06-15 13:50:15 +02:00
CHANGELOG-5.1.md Update CHANGELOG for 5.1.10 2020-12-18 14:43:18 +01:00
CHANGELOG-5.2.md Update CHANGELOG for 5.2.4 2021-03-04 19:05:47 +01:00
CODE_OF_CONDUCT.md Added the Code of Conduct file 2018-10-10 03:13:30 -07:00
CONTRIBUTING.md Mention the community review guide 2016-12-18 22:02:35 +01:00
CONTRIBUTORS.md Add some information about the username in CONTRIBUTORS 2021-02-09 09:21:20 +01:00
LICENSE Bump license year 2021-01-01 10:24:35 +01:00
README.md Update README.md 2020-12-29 01:17:49 +01:00
UPGRADE-5.0.md Merge branch '4.4' into 5.1 2020-12-10 18:44:54 +01:00
UPGRADE-5.1.md Update UPGRADE-5.1.md 2020-09-07 01:58:27 +02:00
UPGRADE-5.2.md [HttpFoundation] Deprecate BinaryFileResponse::create(). 2020-11-20 16:47:02 +01:00
UPGRADE-6.0.md throw type error when incompatible types are passed 2021-01-04 13:51:17 +01:00
composer.json minor #40093 Always autoload string functions on symfony/symfony (chalasr) 2021-02-06 09:57:39 +01:00
link Merge branch '5.1' into 5.2 2020-12-10 20:16:15 +01:00
phpunit Merge branch '4.4' into 5.2 2021-02-11 09:21:20 +01:00
phpunit.xml.dist Merge branch '4.4' into 5.1 2020-11-16 16:58:32 +01:00
psalm.xml Adding a Github action to run Psalm 2021-02-25 17:18:18 +01:00

README.md

Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).

Installation

Documentation

Community

Contributing

Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.

Security Issues

If you discover a security vulnerability within Symfony, please follow our disclosure procedure.

About Us

Symfony development is sponsored by SensioLabs, led by the Symfony Core Team and supported by Symfony contributors.