From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Replication status in logical replication |
Date: | 2017-03-22 02:50:12 |
Message-ID: | CAD21AoB2ZbCCqOx=bgKMcLrAvs1V0ZMqzs7wBTuDySezTGtMZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
When using logical replication, I ran into a situation where the
pg_stat_replication.state is not updated until any wal record is sent
after started up. For example, I set up logical replication with 2
subscriber and restart the publisher server, but I see the following
status for a while (maybe until autovacuum run).
=# select application_name, state, sent_location, write_location,
flush_location, replay_location, sync_state from pg_stat_replication ;
application_name | state | sent_location | write_location |
flush_location | replay_location | sync_state
------------------+---------+---------------+----------------+----------------+-----------------+------------
node1 | catchup | 0/16329F8 | 0/16329F8 |
0/16329F8 | 0/16329F8 | potential
node2 | catchup | 0/16329F8 | 0/16329F8 |
0/16329F8 | 0/16329F8 | async
(2 rows)
It seems that all wal senders have caught up but
pg_stat_replication.state is still "catchup". The reason of this
behavior is that WalSndCaughtUp is updated only in WalSndWaitForWal in
logical replication during running, and in logical_read_xlog_page
always try to read next wal record (i.g. it calls
WalSndWaitForWal(targetPagePtr + reqLen)). So WalSndWaitForWal cannot
update WalSndCaughtUp until any new wal record is created after
started up and wal sender read it.
Attached patch fixes this behavior by updating WalSndCaughtUp before
trying to read next WAL if already caught up.
Regards,
--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
Attachment | Content-Type | Size |
---|---|---|
logical_repl_caught_up.patch | application/octet-stream | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2017-03-22 02:51:45 | Re: Logical decoding on standby |
Previous Message | Peter Eisentraut | 2017-03-22 02:38:06 | Re: logical replication access control patches |