[Bug fix]If recovery.conf has target_session_attrs=read-write, the standby fails to start.
Higuchi, Daisuke <higuchi.daisuke@jp.fujitsu.com>
From: "Higuchi, Daisuke" <higuchi.daisuke@jp.fujitsu.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-05-19T04:16:02Z
Lists: pgsql-hackers
Attachments
- target_session_attrs_in_recovery_conf_v1.patch (application/octet-stream) patch v1
Hello,
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 target_session_attrs=read-write'
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 failed.
'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'.
Regards,
Daisuke, Higuchi
Commits
-
Rethink flex flags for syncrep_scanner.l.
- 5c837ddd7092 10.0 landed
-
Capitalize SHOW when testing whether target_session_attrs=read-write.
- aa41bc794c51 10.0 landed