odoo/odoo#201967

Created by fw-bot
Merged at 0bce293e9f1102f7e3fa88a7f675a7866a09f8f5

Statuses:

label
odoo-dev:saas-18.2-16.0-pg_xact-error-fix-2-wbr-423260-fw
head
d5091b39bc517e2a9504e1336639ac7ca8244246
merged
7 months ago by William Braeckman (wbr)
odoo/odoo
16.0 #201401
17.0 #201787
saas-17.4 #201814
18.0 #201936
saas-18.1 #201964
saas-18.2 #201967
saas-18.3
saas-18.4
19.0
master #201974

[FW][FIX] odoo: improve pg_xact error mitigation

Initial PR: #194141

It seems the fix above was not enough as it was assumed that connection (or backend in pg terms) were NOT being reused when initiated through sql_db.connect.

For proper cleanup we need to reach this part of the code which can be done in 3 ways:
- calling UNLISTEN * and committing
- closing the connection
- aborting the transaction (before committing the listen)

UNLISTEN * is a good candidate for this, but closing the connection seems to be the safer option.

Forward-Port-Of: #201814
Forward-Port-Of: #201401