Doctrinebundle: Automatic connection to configured databases on each Symfony request

Created on 10 Dec 2019  路  4Comments  路  Source: doctrine/DoctrineBundle

We are suffering Postgresql connection spamming coming from our Symfony applications.

After some investigation, we have discovered this :

  • Doctrine connect to every configured database each time a Symfony request is made.
  • Doctrine do this even if no request is done on this database during the request.

We have three databases configured in config.yml/doctrine/dbal/connections.
So we experience connection limit on our database servers !

Can we deactivate this behavior ?

Can Doctrine only connect to the database at the first request ?

DoctrineBundle Version 1.11.2.

Question

All 4 comments

Related to #1070 - I'll defer to @nicolas-grekas 馃槈

Do #1087 fix the issue?
If not, what triggers the actual connection?

this usually happens with misconfigured server_version option

@ostrolucky thanks !

I have added the server_version parameter and the unwanted connection does not occur anymore.

From https://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration:

The server_version option was added in Doctrine DBAL 2.5, which is used by DoctrineBundle 1.3.
...
If you don't define this option and you haven't created your database yet, you may get PDOException errors because Doctrine will try to guess the database server version automatically and none is available.

In a web context, this parameter should be mandatory to avoid the unwanted side-effect of overloading the database server with connections.

Was this page helpful?
0 / 5 - 0 ratings