pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Pg_stat_replication shows sync standby with flush location behind primary in 9.1.5
Date: Thu, 04 Oct 2012 17:32:13 +1300
Message-ID: <506D114D.1050803@catalyst.net.nz> (raw)

I am seeing the situation where the reported flush location for the sync 
standby (standby1 below) is *behind* the reported current xlog location 
of the primary. This is Postgres 9.1.5 , and I was under the impression 
that transactions initiated on the master do not commit until the 
corresponding wal is flushed on the sync standby.

Now the standby is definitely working in sync mode, because stopping it 
halts all write transactions on the primary (sync_standby_names contains 
only standby1). So is the reported lag in flush location merely an 
artifact of timing in the query, or is there something else going on? [1]

db=# SELECT 
application_name,pg_current_xlog_location(),sent_location,write_location,flush_location,replay_location,sync_priority,state
      FROM pg_stat_replication where replay_location is not null;
  application_name | pg_current_xlog_location | sent_location | 
write_location | flush_location | replay_location | sync_priority |   state
------------------+--------------------------+---------------+----------------+----------------+-----------------+---------------+-----------
  standby1         | E/254909E0               | E/25490000    | 
E/2548C3B8     | E/2548C3B8     | E/25476DE0 |             1 | 
streaming   <===
  standby2         | E/254909E0               | E/2548C3B8    | 
E/25476DE0     | E/25476DE0     | E/254724C0 |             0 | streaming
  standby3         | E/254909E0               | E/254909E0    | 
E/25476DE0     | E/25476DE0     | E/254724C0 |             0 | streaming
  standby4         | E/254909E0               | E/25490000    | 
E/2548C3B8     | E/25476DE0     | E/25476DE0 |             0 | streaming
  standby5         | E/254909E0               | E/25490000    | 
E/25476DE0     | E/25476DE0     | E/254724C0 |             0 | streaming
(5 rows)


Cheers

Mark

[1] Looking at the code for pg_stat_replication, it appears to take the 
sync rep lock while reporting, so in theory should be exactly right...I 
should perhaps check what pg_current_xlog_location does...




view thread (3+ messages)  latest in thread

Message-ID: <506D114D.1050803@catalyst.net.nz>
Permalink:  ../506D114D.1050803@catalyst.net.nz/
Also on:    postgresql.org/message-id/506D114D.1050803@catalyst.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: mark.kirkwood@catalyst.net.nz
  Subject: Re: Pg_stat_replication shows sync standby with flush location behind primary in 9.1.5
  In-Reply-To: <506D114D.1050803@catalyst.net.nz>
  References: <506D114D.1050803@catalyst.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox