odoo/odoo#194705

Created by fw-bot
Merged at 5a2032850ddd6d0209d9e7fd39d594f01da7de00

Statuses:

Linked pull requests
label
odoo-dev:17.0-16.0-cron-conn-time-opt-wbr-DoJv-fw
head
1718122c933a41c89da2e06dd0e41de46da46896
merged
5 months ago by William Braeckman (wbr)
odoo/odoo odoo/documentation
16.0 #194141 #11779
17.0 #194705 #11822
saas-17.2 #194742 #11824
saas-17.4 #194822 #11831
18.0 #194937 #11835
saas-18.1 #194957 #11843
saas-18.2
saas-18.3
master #195042 #11851

[FW][IMP] odoo: add config for cron connection time

Adds a configuration that can be used to mitigate PostgreSQL
transactional errors with long-living connections and the
LISTEN/NOTIFY1 functionality by re-establishing the database
connection periodically.

In the case that a connection outlives the transaction wraparound2
mechanism of postgres, the LISTEN/NOTIFY internal queue might contain
references to transactions that have already been deleted by the
system's (or a manual) VACUUM3 as it has its own transaction
validity mechanisms (roughly comparing transaction ids).

This can be reproduced by:
- Triggering a wraparound AND cleaning of pg_xact between the cron's
LISTEN + COMMIT and its recyling.
- Having done at least one NOTIFY during that time period (?).
- Try to LISTEN to the same channel on the same database (transcation
id must be < than the first connection's transaction id).

The following is an example error message:

ERROR database odoo.service.server: Worker (3194772) Exception occurred, exiting...
Traceback (most recent call last):
  File &#34;/home/user/odoo/service/server.py&#34;, line 1089, in run
    self.start()
  File &#34;/home/user/odoo/service/server.py&#34;, line 1235, in start
    self.dbcursor.commit()
  File &#34;/home/user/odoo/sql_db.py&#34;, line 480, in commit
    result = self._cnx.commit()
             ^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedFile: could not access status of transaction 1194816979
DETAIL:  Could not open file &#34;pg_xact/0473&#34;: No such file or directory.

LISTEN/NOTIFY code

Connection being kept

See more

Forward-Port-Of: #194141


  1. https://www.postgresql.org/docs/current/sql-notify.html ↩

  2. https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND ↩

  3. https://www.postgresql.org/docs/17/sql-vacuum.html ↩