PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
23.39k stars 1.03k forks source link

`target_session_attrs=read-only` is only supported on libpq >= 14 #3699

Open steve-chavez opened 2 months ago

steve-chavez commented 2 months ago

Problem

The docs instruct to add target_session_attrs=read-only to the db-uri, but this will fail on an instance with libpq < 14:

"Failed to query the role settings. {"code":"PGRST000","details":"invalid target_session_attrs value: \"read-only\"\n","hint":null,"message":"Database connection error. Retrying the connection."}"

(uses the ubuntu-aarch64 release)

This happens because target_session_attrs only accepts read-only starting from libpq 14. target_session_attrs only supports read-write on libpq13, see https://www.postgresql.org/docs/13/libpq-connect.html#LIBPQ-CONNECT-TARGET-SESSION-ATTRS.

Solution

Warn about this limitation on the docs.

steve-chavez commented 2 months ago

Edit: fixed the issue

Wait, this is wrong. We actually set target_session_attrs=read-write internally.

It's the db-uri on the docs the one that's set to read-only: https://postgrest.org/en/v12/references/listener.html#listener-on-read-replicas

I'll fix this by putting warning on the docs.