odoo/odoo#159569

Created by fw-bot
label
odoo-dev:saas-17.1-15.0-perf-3650618-pivi-sDcn-fw
head
268517d198c53bdec8654eabe639708dba09b2cb
target
saas-17.1
merged
2 months ago by Piryns Victor (pivi)
forward-port of
odoo/odoo#154463

[FW][FIX] bus: split large `NOTIFY` payloads

## Description
On a database with heavy activity, it is possible for the payload size we pass for the `NOTIFY` query on the bus to be larger than what PostgreSQL allows by default, 8000 B. This limit is defined as [src1](https://github.com/postgres/postgres/blob/6686e9676c8faff4ee04c1574e117ae38f117efa/src/backend/commands/async.c#L158-L166) and is used to compare the size of the payload before processing [src2](https://github.com/postgres/postgres/blob/6686e9676c8faff4ee04c1574e117ae38f117efa/src/backend/commands/async.c#L654-L657)

## Fix
- Binary split the payload into multiple chunks if it's exceeding the above-mentioned limit. The unit of splitting is a channel, so if the content of one channel itself is larger than said limit, it is not handled, but shouldn't occur under normal circumstances.
- Introduce also a new ENV variable `ODOO_NOTIFY_PAYLOAD_MAX_LENGTH` to allow tweaking of the limit if they are running a handrolled custom PostgreSQL cluster.

## Reference
opw-3650618

---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: odoo/odoo#159469
Forward-Port-Of: odoo/odoo#154463