[feature] support setting target_session_attrs postgres option by passing additional options to a django database backend
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Invalid
|
Medium
|
Unassigned |
Bug Description
libpq coming with PostgreSQL 10 has support for multiple hostnames and IP addresses and iterating over them until it finds a good endpoint to connect to. It also supports resolving a single hostname with multiple address records backing it and iterating over those. However target_
# without target_
python -c "import psycopg2; psycopg2.
# with target_
python -c "import psycopg2; psycopg2.
https:/
Parsing and handling: https:/
This explains that target_
https:/
“any”, meaning that any kind of servers can be accepted. This is as well the default value.
“read-write”, to disallow connections to read-only servers, hot standbys for example.
"If a failover happens and a standby is promoted and switches to be a primary, target_
MAAS relies on django and psycopg2 backend to connect to postgres.
https:/
However, it does not allow passing OPTIONS which could contain "target_
https:/
"Extra parameters to use when connecting to the database. Available parameters vary depending on your database backend."
Using the default setting target_
"host=host1,
This simplifies the logic at application level: there is no need for it to know exactly which node is the primary and which ones are the standbys. The cost though, is an increase in connection failures when using the read-write mode, but that may be acceptable if the cluster is in a low-latency environment."
~~
Looks like people did not have any real issues in using this via psycopg2:
https:/
https:/
~~
On failover handling:
From the perspective of using a VIP and gratuitous ARP type of failover on a single subnet (with Pacemaker managing the VIP and GARP), it doesn't look like there is a big difference with the multi-endpoint setup:
We do not have any TCP connection state synchronization as in LVS http://
on failover a client recreates a TCP connection to the same VIP endpoint.
In the case of multiple endpoints we would just try several of them before the client lib would declare the connection as failed when creating a new connection or during failover handling.
The bulk of the client logic is in PQconnectPoll and the rest should be handled in the client library (psycopg2 that uses libpq).
https:/
https:/
summary: |
- support setting target_session_attrs postgres option by passing - additional options to a django database backend + [feature] support setting target_session_attrs postgres option by + passing additional options to a django database backend |
Changed in maas: | |
status: | New → Triaged |
tags: | added: feature |
description: | updated |
Changed in maas: | |
milestone: | 2.5.x → next |
Changed in maas: | |
milestone: | next → 2.6.0 |
Changed in maas: | |
assignee: | nobody → Blake Rouse (blake-rouse) |
Hi Dmitrii,
In what version of psycopg was this introduced/ supported?
Also, allowing the passing of options would mean that you would change the behavior of how MAAS connects to PostgreSQL. If that is to cause any issue with MAAS or break things, this would be an unsupported configuration provided that this is not something that the team has tested or validated or event made sure MAAS can work with. THis is because any region can write to postgresql and could potentially lead to issues we won't be able to resolve.
That said, do you have any production clusters that are doing this today by manually modifying MAAS?