pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to know current xlog location on standby after primary is down
2+ messages / 2 participants
[nested] [flat]

* how to know current xlog location on standby after primary is down
@ 2018-09-09 14:29 magodo <wztdyl@sina.com>
  2018-09-10 06:50 ` Re: how to know current xlog location on standby after primary is down Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 2+ messages in thread

From: magodo @ 2018-09-09 14:29 UTC (permalink / raw)
  To: pgsql-general


Hello, 

I'm working on a high availability project for PG(v9.6).

Suppose I have a priamry-standby setup, I need to do promote once
primary is down, but only when standby is as new as primary (before it
is down). Therefore, I need a way to know the wal replay location on
standby.

I tried to set a hot standby, but it failed to run
`pg_current_xlog_location()` on it; I also tried `pg_xlogdump` on
standby, but it has following cavets:

- hard to identify latest used wal segment, since there are some
renamed reservations
- sometimes `pg_xlogdump` will raise errors like: "pg_xlogdump:
FATAL:  error in WAL record at 0/9F88F0F8: record with incorrect prev-
link 2020/20202020 at 0/9F88F130"

So I want to know what is the correct way to do it. Thank you in
advance!






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: how to know current xlog location on standby after primary is down
  2018-09-09 14:29 how to know current xlog location on standby after primary is down magodo <wztdyl@sina.com>
@ 2018-09-10 06:50 ` Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2018-09-10 06:50 UTC (permalink / raw)
  To: magodo <wztdyl@sina.com>; +Cc: pgsql-general

On Sun, Sep 09, 2018 at 10:29:08PM +0800, magodo wrote:
> So I want to know what is the correct way to do it. Thank you in
> advance!

There are pg_last_wal_receive_lsn() and pg_last_wal_replay_lsn() which
allow you to know what is the last LSN received and replayed on a
standby.  Those can be used when an instance is in recovery.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-09-10 06:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09 14:29 how to know current xlog location on standby after primary is down magodo <wztdyl@sina.com>
2018-09-10 06:50 ` Michael Paquier <michael@paquier.xyz>

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