Skip to content
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

Migrations Always Starting a Transaction #1413

Closed
BusterNeece opened this issue Mar 7, 2024 · 4 comments
Closed

Migrations Always Starting a Transaction #1413

BusterNeece opened this issue Mar 7, 2024 · 4 comments

Comments

@BusterNeece
Copy link
Contributor

BusterNeece commented Mar 7, 2024

Bug Report

Q A
Version 3.7.4

Summary

Trying to track down an issue I'm having since updating to ORM 3, DBAL 4 and the latest Migrations library.

Basically, regardless of what setting I provide at the global configuration level for the transactional variable, it seems to still be wrapping every migration in a transaction that it isn't then exiting out of at the end of that migration completing successfully.

This means that if I have 30 database migrations to execute, I'll wind up, at the end of that command's execution, with a nesting level of 30 as reported by the DBAL.

I've gone digging through the relevant code and found that currently the only place the migrator executor is checking for whether or not to wrap each migration in a transaction is in AbstractMigration::isTransactional. It doesn't seem to be using the global configuration for that at all currently.

As for why it isn't committing those transactions when successful, I haven't been able to figure that out.

I suspect that this has been a nonissue for most users because they run DB migrations as an isolated command, and the migrations do complete successfully either way, so whatever state the DBAL is left in after the migrations execute is of no concern to most people implementing the library. In my case, I execute a few other "cleanup" commands after the migrations complete, and it's these commands that break as a result of the DBAL being left, by the migrator, in a state with nested transactions that it can't seem to deal with properly.

Current behaviour

Previously this didn't cause any problems in earlier versions of the Migrations library, though unfortunately I upgraded to both DBAL 4 and ORM 3 at the same time, meaning the error could theoretically be in any of the relevant upstream projects. I was able, however, to identify at least one specific problem (the isTransactional check above not using the global config value at all), that likely merits fixing on this library's level.

I can confirm, however, that if you return false on isTransactional for all migration classes themselves, they won't wrap in a transaction and this is not an issue.

How to reproduce

I'll work on getting this in a reproducible way; right now it's embedded in a rather complex application that would be difficult to pull apart for diagnostics here.

Expected behaviour

Either for migrations to not take place wrapped in transactions at all (honoring the is_transactional global setting sent to migration config) or for the nested transaction level at the end of multiple migrations to be 0.

@derrabus derrabus transferred this issue from doctrine/dbal Mar 8, 2024
@derrabus
Copy link
Member

derrabus commented May 3, 2024

Is your database a MySQL or MariaDB by any chance?

@BusterNeece
Copy link
Contributor Author

@derrabus MariaDB, yes

@derrabus
Copy link
Member

derrabus commented May 3, 2024

See #1426.

@BusterNeece
Copy link
Contributor Author

Yep, closing this in favor of that. Same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants