Skip to content

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 1, 2025

Q A
Branch? 7.4
Bug fix? yes
New feature? yes
Deprecations? no
Issues Fix #54348
License MIT

The isSameDatabaseChecker feature of the SchemaListener detect if 2 DBAL connections are connected to the same server and database by creating a temporary table with one connection and checking if the table exists using the other connection.

Creating a temporary table with a random name cause an issue to configure permissions, as an exhaustive list of table names can be required.

I propose to modify the implementation to always use the same table name, but insert a row with a random key with one connection and try to delete it with the other connection.
The table is dropped only if it is empty, to prevent concurrence issues.

@carsonbot carsonbot added this to the 7.4 milestone Sep 1, 2025
@GromNaN GromNaN changed the title [DoctrineBridge] Use a single table in SchemaListener isSameDatabaseChecker [DoctrineBridge] Use a single table in isSameDatabaseChecker Sep 1, 2025
Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GromNaN GromNaN force-pushed the same-database-checker branch 3 times, most recently from ec4ed73 to 579a34e Compare September 3, 2025 07:36
@nicolas-grekas
Copy link
Member

(rebase needed)

@GromNaN GromNaN force-pushed the same-database-checker branch from 579a34e to 0c5b355 Compare September 3, 2025 14:44
@GromNaN
Copy link
Member Author

GromNaN commented Sep 3, 2025

Rebased. I also added a functional test using 2 in-memory sqlite databases. Other tests use mocks.

@GromNaN GromNaN force-pushed the same-database-checker branch 3 times, most recently from 8a5d0d4 to 842f10e Compare September 3, 2025 15:28
@nicolas-grekas
Copy link
Member

Thank you @GromNaN.

@nicolas-grekas nicolas-grekas merged commit d052b75 into symfony:7.4 Sep 3, 2025
9 of 11 checks passed
nicolas-grekas added a commit that referenced this pull request Sep 4, 2025
This PR was merged into the 7.4 branch.

Discussion
----------

[DoctrineBridge] Fix

| Q             | A
| ------------- | ---
| Branch?       | 7.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

Introduced in #61582

Commits
-------

d9ca867 [DoctrineBridge] Fix
@GromNaN GromNaN deleted the same-database-checker branch September 4, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doctrine Bridge creating random tables prevents fine grained database permissions
6 participants