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

AiiDA opening two connections per daemon instance #2039

Closed
muhrin opened this issue Oct 9, 2018 · 1 comment
Closed

AiiDA opening two connections per daemon instance #2039

muhrin opened this issue Oct 9, 2018 · 1 comment

Comments

@muhrin
Copy link
Contributor

muhrin commented Oct 9, 2018

This issue may apply beyond just the daemon but this is where it's easiest to see.

To reproduce:

  1. Log in a psql shell and run SELECT sum(numbackends) FROM pg_stat_database;, note the number
  2. verdi devel run_daemon
  3. Check SELECT sum(numbackends) FROM pg_stat_database; again. It is likely that there will be 2.

This seems to happen with both Django and SQLA and contrary to my initial thoughts it's not because of the 'new' kiwipy communicator which has a seperate thread.

The second connection (at least in SQLA) seems to be opened when (or around) this line is called: https://github.com/aiidateam/aiida_core/blob/ebf16441a3910d5b783100c13ddf3b5f6fcc6b1f/aiida/backends/sqlalchemy/globalsettings.py#L53

Unfortunately because of the connection pool this new connection will remain open. One way to get around this is to set the pool size to 1 in create_engine but I don't know how safe this is...

@sphuber
Copy link
Contributor

sphuber commented Feb 17, 2022

This seems to no longer be a problem. Tested this after #5330 was merged, at which point only SqlAlchemy is still supported and I only see a single connection to postgres when running verdi devel run_daemon.

@sphuber sphuber closed this as completed Feb 17, 2022
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

2 participants