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

Automatic connection to configured databases on each Symfony request #1088

Closed
vtexier opened this issue Dec 10, 2019 · 4 comments
Closed

Automatic connection to configured databases on each Symfony request #1088

vtexier opened this issue Dec 10, 2019 · 4 comments
Labels
Question Support questions

Comments

@vtexier
Copy link

vtexier commented Dec 10, 2019

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.

@alcaeus
Copy link
Member

alcaeus commented Dec 10, 2019

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

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 10, 2019

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

@ostrolucky
Copy link
Member

this usually happens with misconfigured server_version option

@vtexier
Copy link
Author

vtexier commented Dec 12, 2019

@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.

@vtexier vtexier closed this as completed Dec 12, 2019
@alcaeus alcaeus added Question Support questions and removed Status: Waiting feedback labels Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Support questions
Projects
None yet
Development

No branches or pull requests

4 participants