Thursday, November 7, 2024
1 change · saas-17.4
Enhancements to existing features
Odoo now falls back to the main database when a read-only replica is unavailable or not ready. This helps keep the service usable during replica outages or restarts, reducing disruption for users while temporarily disabling read-only replica use until the worker restarts.
Original PR description
When using Odoo with a read-only replica, it is necessary for the replica to be online, otherwise read-only requests will fail. This commit implements a simple failover mechanism: if a RO cursor…
When using Odoo with a read-only replica, it is necessary for the replica to be online, otherwise read-only requests will fail. This commit implements a simple failover mechanism: if a RO cursor cannot be acquired, we fall back to the RW cursor. We also deactivate the RO feature by setting `_db_readonly` to `None`. It will have the effect of deactivating the RO feature for the subsequent requests until Odoo is restarted or the worker is recycled. In the context of the Postgres replication, such behavior is useful since synchronous replication doesn't guarantee that the replica is actually up-to-date in some edge cases. The most common case being the unexpected restart of the replica: there is a short period of time during which the replica accepts incoming requests but is still catching up with the master. Delaying the use of the replica should help reducing the race conditions in such cases. Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr