AiiDA opening two connections per daemon instance #2039
Labels
priority/nice-to-have
topic/daemon
topic/database-schema
type/enhancement
type/performance
Issue related to how quickly AiiDA works
Milestone
This issue may apply beyond just the daemon but this is where it's easiest to see.
To reproduce:
SELECT sum(numbackends) FROM pg_stat_database;
, note the numberverdi devel run_daemon
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...The text was updated successfully, but these errors were encountered: