2ndQuadrant / pglogical

Logical Replication extension for PostgreSQL 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4 (Postgres), providing much faster replication than Slony, Bucardo or Londiste, as well as cross-version upgrades.
http://2ndquadrant.com/en/resources/pglogical/
Other
987 stars 153 forks source link

Connections parameters overridden by hard-coded values #453

Open dubek opened 8 months ago

dubek commented 8 months ago

It seems that function pglogical_connect_base overrides the values of the following connection-string parameters, if given by the user:

This means that as of pglogical 2.4.4 there's no way to change the value of these parameters for a pglogical connection.

For example, if I set connect_timeout to an illegal non-numeric value (zzzzzz) I get no error:

SELECT pglogical.create_subscription(
  subscription_name := 'sub1',
  provider_dsn := 'host=localhost port=5432 dbname=src user=repuser password=password123 connect_timeout=zzzzzz'
);

because the illegal value is overridden by the hard-coded value of 30 that appears in pglogical.c.

If I try using such illegal value for a parameter that is not overridden (such as tcp_user_timeout), I get the expected error message:

SELECT pglogical.create_subscription(
  subscription_name := 'sub1',
  provider_dsn := 'host=localhost port=5432 dbname=src user=repuser password=password123 tcp_user_timeout=zzzzzz'
);

ERROR:  could not connect to the postgresql server: connection to server at "localhost" (127.0.0.1), port 5432 failed: invalid integer value "zzzzzz" for connection option "tcp_user_timeout"
connection to server at "localhost" (::1), port 5432 failed: invalid integer value "zzzzzz" for connection option "tcp_user_timeout"

Related:

It is not clear to me where pglogical.extra_connection_options is used: it is appended to s here:

https://github.com/2ndQuadrant/pglogical/blob/bff71f2c6b0bd9748ecee15dcc93201cd1a145a0/pglogical.c#L278-L285

but that s is never used. Maybe s.data should be used instead of connstr on line 284.