I found a problem with libpq connection failover. 
If primary_conninfo in recovery.conf has 'target_session_attrs=read-write', the 
standby fails to start. 

How to reproduce the bug: 
1. Prepare two standby (standby_1, standby_2) for one master.
   On standby_1, primary_conninfo in recovery.conf specifies master. 
   On standby_2, primary_conninfo in recovery.conf specifies master and 
standby_2 and target_session_attrs=read-write.
   For example, the standby_2's recovery.conf setting is as follows.
   standby_mode = 'on'
   primary_conninfo = 'host=localhost,localhost port=5432,5433 
   recovery_target_timeline = 'latest'
2. Starts master, standby_1 and standby_2. When try to start standby_2, the 
following error is output. 
          Test "show transaction_read_only" failed on "localhost: 5432"
          ERROR: not connected to database
          Test "show transaction_read_only" failed on "localhost: 5433"
          ERROR: not connected to database
I wanted to test if standby_2 re-connects to the new master when master is 
stopped and standby_1 is promoted, but I failed at the start-up stage.

The reason of this problem is that sending 'show transaction_read_only' is 
'show' must be in uppercase letters because the streaming replication protocol 
only accepts capital letters. 
In psql and libpq applications that do not use the streaming replication 
protocol, this error does not occur.

The attached patch fixes this. This patch changes 'show transaction_read_only' 
to 'SHOW transaction_read_only'.

Daisuke, Higuchi

Attachment: target_session_attrs_in_recovery_conf_v1.patch
Description: target_session_attrs_in_recovery_conf_v1.patch

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to