[Bug fix]If recovery.conf has target_session_attrs=read-write, the standby fails to start.

From: "Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: [Bug fix]If recovery.conf has target_session_attrs=read-write, the standby fails to start.
Date: 2017-05-19 04:16:02
Message-ID: 1803D792815FC24D871C00D17AE95905B1A34A@g01jpexmbkw24
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
target_session_attrs_in_recovery_conf_v1.patch application/octet-stream 2.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-05-19 04:40:49 Re: different column orders in regression test database
Previous Message Huong Dangminh 2017-05-19 04:10:09 Re: [ANNOUNCE] PostgreSQL 10 Beta 1 Released!