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

Skip to content

[Messenger] PostgreSQL: NOTIFY won't work with decorated DBAL driver #45835

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
Sajito opened this issue Mar 24, 2022 · 0 comments
Closed

[Messenger] PostgreSQL: NOTIFY won't work with decorated DBAL driver #45835

Sajito opened this issue Mar 24, 2022 · 0 comments

Comments

@Sajito
Copy link

Sajito commented Mar 24, 2022

Symfony version(s) affected

5.1.8 and up

Description

When using the DoctrineTransport with PostgreSQL, the queue table is created with a trigger to enable LISTEN/NOTIFY feature.
This is done by checking if the driver is an instance of AbstractPostgreSQLDriver.

if ($useNotify && $driverConnection->getDriver() instanceof AbstractPostgreSQLDriver) {
$connection = new PostgreSqlConnection($configuration, $driverConnection);
} else {
$connection = new Connection($configuration, $driverConnection);
}

This check won't work though, if the driver is decorated. This then leads to missing trigger to use the LISTEN/NOTIFY feature.

How to reproduce

I experienced this when when having sentry/sentry-symfony installed.
My sentry.yaml looks like this:

sentry:
  dsn: "%env(SENTRY_DSN)%"
  register_error_listener: false
  options:
    environment: "%env(SENTRY_ENV)%"
    # release: "%env(VERSION)%" #your app version

monolog:
  handlers:
    sentry:
      type: sentry
      level: !php/const Monolog\Logger::ERROR
      hub_id: Sentry\State\HubInterface

Possible Solution

Currently the check is done by checking the instance of the driver in the DoctrineTransportFactory.

if ($useNotify && $driverConnection->getDriver() instanceof AbstractPostgreSQLDriver) {

Instead of checking the Driver itself, we might get the platform and check if the platform is of type PostgreSQLPlatform like so:

if ($useNotify && $driverConnection->getDriver()->getDatabasePlatform() instanceof PostgreSQLPlatform) {

Is this a viable solution or do I miss something here?

Additional Context

No response

@Sajito Sajito added the Bug label Mar 24, 2022
@fabpot fabpot closed this as completed Apr 12, 2022
fabpot added a commit that referenced this issue Apr 12, 2022
… decorated PostgreSQL driver (alamirault)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #45835
| License       | MIT
| Doc PR        |

This PR allow to use Notify connection with Decorated PostgreSQL driver and not only for `AbstractPostgreSQLDriver`

Commits
-------

07c3125 [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver
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

3 participants