This question has been flagged
4 Replies
20990 Views

Hello guys,

I am currently hosting a dozen of Odoo databases on one server. I use docker, with one container containing postgresql and five with odoo services. There is not many visitors yet. I use a recent pull of Odoo 8 from github and 9.4 version of postgres (it was the same with 9.1)

My problem is, after a dozen of hours I have almost an hundred of idle process in the postgres container, all related with the Odoo databases. It seems the connections to postgres never close.

I checked SELECT * FROM pg_stat_activity;, it seems the idle query is always COMMIT or ROLLBACK. Do you have any idea where the problem comes and how I can improve the situation? Do you think it's related on the use of docker?

Thanks,
Yannick.

Avatar
Discard

Hy, I have the same problem with V7 and postgresql 9.3 and without docker on ubuntu server 14.04.1 After users deconnect from OpenERP, their postgresql process stay active : postgres 23905  1.4  1.7 256692 36996 ?        Ss   10:36   0:05 postgres: openerp7 xxxxxx [local] idle postgres 24019  0.3  1.7 259516 36184 ?        Ss   10:36   0:01 postgres: openerp7 xxxxxxx [local] idle postgres 24631  0.2  1.6 264400 34856 ?        Ss   10:38   0:00 postgres: openerp7 xxxxxxx [local] idle postgres 24452  0.3  1.6 259576 34752 ?        Ss   10:38   0:00 postgres: openerp7 xxxxxxxx [local] idle postgres 23913  0.5  1.6 259252 34424 ?        Ss   10:36   0:02 postgres: openerp7 xxxxxxxx [local] idle postgres 24247  1.2  1.6 256408 34100 ?        Ss   10:37   0:03 postgres: openerp7 xxxxxxxx [local] idle postgres 24534  0.2  1.5 259420 31896 ?        Ss   10:38   0:00 postgres: openerp7 xxxxxxxxx [local] idle Each user (student) has his own database. Thanks Patrick

Author Best Answer

Credit to @panos_xrg and @reis_pt for pointing me in the good direction https://twitter.com/panos_xrg/status/556460140149633026 https://twitter.com/reis_pt/status/556456989170339841

It seems it's the official strategy of Odoo to keep connection to postgres open, at least if what was said in this very old thread https://bugs.launchpad.net/openobject-server/+bug/463219 is still true.

I have a dozen of odoo services connected to the same postgres, each having five database to manage with 4 workers. I still can't found how many connections are opened for each services/database/workers and under which conditions but it doesn't seems to be really controled and it finally reach the 100 connections which is the limit of my postgres configuration.

In the F3 fork @panos_xrg decided to automatically close all connections older that 300seconds https://github.com/xrg/openerp-server/commit/b215015ba0453a. After playing a little with the odoo config, I found that there is a way to achieve the same thing which the official Odoo, it's the db_maxconn parameter.
When the number of opened connection in an odoo service reach the db_maxconn limit, it's seems the oldest connections are automatically closed. Looks like the way to go for me, and I guess that the rules are :

-The sum of all db_maxconn settings for each odoo services connected to the same postgres shall be less that this postgres maxconn configuration.

-The db_maxconn settings for an odoo service shall be high enough to manage the concurrent requests on this service.

So I'll try to set a db_maxconn settings to 10 on each of my odoo services, and I hope this will resolve the problem. I guess this is an important information to have in mind when you want like me to make many odoo services connected to same postgres, and not one big odoo service connected to one postgres (like Odoo SA if I'm not mistaking) nor several odoo services having each their own postgres (like most of the other odoo hosting).

Avatar
Discard

Yes using the db_maxconn to this purpose is correct, and your can do the maths when you need to determine the max_connections settings for your PG cluster according to the number of Odoo processes/workers that will connect to it and their db_maxconn setting (keeping in mind that the db_maxconn setting applies *per-process*, so with `--workers` > 1, each worker can have up to db_maxconn open connections.

Best Answer

" ... each worker can have up to db_maxconn open connections."

Then is there a setting or a way to limit the absolut number of processes ?

Edit : Ok I finally get what this worker stuff is about, learning, learning ...

Avatar
Discard