Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[messenger][Doctrine] doctrine:schema:create breaks #40130

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

Closed
alexdruhet opened this issue Feb 8, 2021 · 10 comments
Closed

[messenger][Doctrine] doctrine:schema:create breaks #40130

alexdruhet opened this issue Feb 8, 2021 · 10 comments

Comments

@alexdruhet
Copy link

alexdruhet commented Feb 8, 2021

Symfony version affected: 5.2.3

Description
Using Postgresql and symfony/doctrine-messenger, upgrading to symfony/doctrine-messenger 5.2.3 breaks doctrine:schema:create command.

How to reproduce
bin/console doctrine:schema:create

Possible Solution
The bug was introduced by PR #40055. Reverting it solve the issue but also reopens #39928. This must be taking into account to define a PR.

For now I have put a composer version constraint:

...
"symfony/doctrine-messenger": "^5.1 <5.2.3",
...

Additional context
The response returned by bin/console doctrine:schema:create:

In ToolsException.php line 34:

Schema-Tool failed with Error 'An exception occurred while executing 'LOCK TABLE messenger_messages;':

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

In AbstractPostgreSQLDriver.php line 102:

An exception occurred while executing 'LOCK TABLE messenger_messages;':

SQLSTATE[25P01]: No active sql transaction: 7 ERROR: LOCK TABLE can only be used in transaction blocks

In Exception.php line 18:

SQLSTATE[25P01]: No active sql transaction: 7 ERROR: LOCK TABLE can only be used in transaction blocks

In PDOConnection.php line 125:

SQLSTATE[25P01]: No active sql transaction: 7 ERROR: LOCK TABLE can only be used in transaction blocks

doctrine:schema:create [--dump-sql] [--em [EM]]

@alexdruhet alexdruhet added the Bug label Feb 8, 2021
@alexdruhet alexdruhet changed the title [messenger][Doctrine] [messenger][Doctrine] doctrine:schema:create breaks Feb 8, 2021
@jrushlow
Copy link
Contributor

jrushlow commented Feb 9, 2021

I'm having a similar issue when attempting to run tests using https://github.com/zenstruck/foundry or when running bin/console messenger:setup-transports

@alexdruhet
Copy link
Author

In my opinion, if the case exposed in #39928 can be solved by manipulating transaction within migration, it would be right to revert #40055 to avoid breaking backwards compatibility.

@baiiko
Copy link

baiiko commented Feb 12, 2021

Hi people, i've this problem too.

If you don't use auto setup, you app need a migration, or if you use auto setup, juste apply messenger:setup-transports with the first fix #38136.

@alexdruhet
Copy link
Author

alexdruhet commented Feb 12, 2021

If you don't use auto setup, you app need a migration, or if you use auto setup, juste apply messenger:setup-transports to with the first fix #38136.

I agree with auto setup case. Indeed #40055 override #38136 and cause this issue.

@baiiko
Copy link

baiiko commented Feb 12, 2021

yes but with auto setup, this case #40055 does not work

@alexdruhet
Copy link
Author

yes but with auto setup, this case #40055 does not work

we agree, that's what I meant

@Nyholm
Copy link
Member

Nyholm commented Mar 1, 2021

Hey @alexdruhet
Do you have a suggestion how to fix this issue?

@alexdruhet
Copy link
Author

Hi @Nyholm,
my initial suggestion would be to revert #40055 as #38136 worked very fine with my setup. But it depends on the edge case exposed by #39928. Considering that last can be resolved by starting/closing the transaction "manually" in the generated migration, this may be a compromise we can be satisfied with.

@Nyholm
Copy link
Member

Nyholm commented Mar 1, 2021

I agree with you. I started a PR and I will work to fix #39928 in a different way.
I'll also add some tests to make sure this is happening again.

@alexdruhet
Copy link
Author

I just see that, thanks for helping!

@fabpot fabpot closed this as completed Mar 4, 2021
fabpot added a commit that referenced this issue Mar 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants