Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

PostgreSQL Idle connections and docker

By
YannickB
on 1/10/15, 6:21 AM 5,937 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.

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

Patrick Aymar
on 1/13/15, 5:09 AM
6
YannickB
On 1/17/15, 10:45 AM

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

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.

Olivier Dony (odo)
on 1/19/15, 5:39 AM
0
Felipe
On 10/11/16, 10:38 AM

hola

0
Patrick Aymar
On 2/3/15, 4:45 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

8 follower(s)

Stats

Asked: 1/10/15, 6:21 AM
Seen: 5937 times
Last updated: 10/11/16, 10:38 AM