Skip to content

8.0 jobrunner: support pgbouncer. named cursor to iterate jobs.#520

Open
a0c wants to merge 2 commits intoOCA:8.0from
a0c:8-jobrunner-imp
Open

8.0 jobrunner: support pgbouncer. named cursor to iterate jobs.#520
a0c wants to merge 2 commits intoOCA:8.0from
a0c:8-jobrunner-imp

Conversation

@a0c
Copy link

@a0c a0c commented Feb 10, 2026

  1. jobrunner: use named cursor to iterate jobs. backport of OCA/queue@ae3e64ee and OCA/queue@f0fc575f with fixed line for job_data in cr.fetchall():.
  2. jobrunner: support pgbouncer via db_session_pool_mode_suffix config.

PGBouncer is typically configured with pool_mode = transaction that does not support LISTEN/NOTIFY of postgre. This patch adds support of additional pool_mode = session entry, thus allowing connector module to work as it fully relies on LISTEN/NOTIFY.

LISTEN/NOTIFY is used by bus.bus (IM), web_auto_refresh, connector etc.

Example odoo.conf:

db_name = odoo
db_session_pool_mode_suffix = _bus

Example pgbouncer.ini with additional entries in pool_mode=session (odoo_bus, postgres_bus):

[databases]
odoo = host=xx.xx.xx.xx port=yy dbname=odoo pool_mode=transaction
odoo_bus = host=xx.xx.xx.xx port=yy dbname=odoo pool_mode=session pool_size=5
postgres = host=xx.xx.xx.xx port=yy dbname=postgres pool_size=20
postgres_bus = host=xx.xx.xx.xx port=yy dbname=postgres pool_mode=session pool_size=5

[pgbouncer]
pool_mode = transaction

a0c added 2 commits February 9, 2026 18:03
Instead of fetching all jobs at once and then inserting them in
the channels queue, fetch them by chunks of 2000 (default
named cursor iterator behaviour since psycopg 2.4).

This has the benefit of releasing the GIL periodically while
loading jobs as well as consuming less memmory.

backport of ae3e64ee27e8467380... and f0fc575fae36663409... with fixed
line `for job_data in cr.fetchall():`.
pgbouncer is typically configured with `pool_mode = transaction` that
does not support LISTEN/NOTIFY of postgre. support alt. `session` entry.

LISTEN/NOTIFY is used by bus.bus (IM), web_auto_refresh, connector etc.

Example odoo.conf:
db_session_pool_mode_suffix = _bus

Example pgbouncer.ini with additional entries in `pool_mode=session`
(odoo_bus, postgres_bus):
[databases]
odoo = host=xx.xx.xx.xx port=yy dbname=odoo pool_mode=transaction
odoo_bus = host=xx.xx.xx.xx port=yy dbname=odoo pool_mode=session
pool_size=5
postgres = host=xx.xx.xx.xx port=yy dbname=postgres pool_size=20
postgres_bus = host=xx.xx.xx.xx port=yy dbname=postgres pool_mode=session
pool_size=5

[pgbouncer]
pool_mode = transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant