Support of the "target_session_attrs" attribute for postgresql connection
Feature Request
| Q | A |
|---|---|
| New Feature | yes |
| RFC | no |
Summary
Hello,
I'm working on a symfony project with postgreqsql and multiple hosts for database. There is primary server and a replicated server. In my configuration, i set two IP in doctrine.dbal.connections.default.host, separated by coma. Example : 192.10.11.12,192.10.11.13 192.10.11.12 is my primary server, 192.10.11.13 is my replicated server. And it works. Even if my primary server crashes and the replicated become the new primary, it always works.
But if i invert the two IP, it doesn't work because all the requests reach the replicated server (the first IP) which is only in read-only mode. I need to say to postgresql : "send requests only on my primary server" (it doesn't matter if it's the 1st or the 2nd IP) It's why I need to specify the "target_session_attrs", in my case, with the value "primary".
Here the pgsql documentation for this attribute : https://www.postgresql.org/docs/current/libpq-connect.html
Is it possible to add this new attribute in https://github.com/doctrine/dbal/blob/3.6.x/src/Driver/PgSQL/Driver.php, like sslmode attribute ?
Thanks in advance.
If the PgSQL extension allows you to configure that attribute, we can certainly add support for it. Do you want to give it a try?
@derrabus It would be great if you could add attributes target_session_attrs via DSN string https://github.com/doctrine/dbal/blob/4.0.x/src/Driver/PgSQL/Driver.php#L65
I'm not doing anything, sorry. If you need this, send a PR.