pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Non-null values of recovery functions after promote or crash of primary
3+ messages / 2 participants
[nested] [flat]

* Non-null values of recovery functions after promote or crash of primary
@ 2019-10-05 11:43 Martín Marqués <martin@2ndquadrant.com>
  2019-10-08 18:03 ` Re: Non-null values of recovery functions after promote or crash of primary Stephen Frost <sfrost@snowman.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Martín Marqués @ 2019-10-05 11:43 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org, PostgreSQL-development <pgsql-hackers@postgresql.org>

Hi,

Yesterday we (that's me and my colleague Ricardo Gomez) were working on
an issue where a monitoring script was returning increasing lag
information on a primary instead of a NULL value.

The query used involved the following functions (the function was
amended to work-around the issue I'm reporting here):

pg_last_wal_receive_lsn()
pg_last_wal_replay_lsn()
pg_last_xact_replay_timestamp()

Under normal circumstances we would expect to receive NULLs from all
three functions on a primary node, and code comments back up my thoughts.

The problem is, what if the node is a standby which was promoted without
restarting, or that had to perform crash recovery?

So during the time it's recovering the values in ` XLogCtl` are updated
with recovery information, and once the recovery finishes, due to crash
recovery reaching a consistent state, or a promotion of a standby
happening, those values are not reset to startup defaults.

That's when you start seeing non-null values returned by
`pg_last_wal_replay_lsn()`and `pg_last_xact_replay_timestamp()`.

Now, I don't know if we should call this a bug, or an undocumented
anomaly. We could fix the bug by resetting the values from ` XLogCtl`
after finishing recovery, or document that we might see non-NULL values
in certain cases.

Regards,

-- 
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services





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

* Re: Non-null values of recovery functions after promote or crash of primary
  2019-10-05 11:43 Non-null values of recovery functions after promote or crash of primary Martín Marqués <martin@2ndquadrant.com>
@ 2019-10-08 18:03 ` Stephen Frost <sfrost@snowman.net>
  2019-10-08 19:56   ` Re: Non-null values of recovery functions after promote or crash of primary Martín Marqués <martin@2ndquadrant.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Stephen Frost @ 2019-10-08 18:03 UTC (permalink / raw)
  To: Martín Marqués <martin@2ndquadrant.com>; +Cc: pgsql-bugs@lists.postgresql.org, PostgreSQL-development <pgsql-hackers@postgresql.org>

Greetings,

* Martín Marqués (martin@2ndquadrant.com) wrote:
> pg_last_wal_receive_lsn()
> pg_last_wal_replay_lsn()
> pg_last_xact_replay_timestamp()
> 
> Under normal circumstances we would expect to receive NULLs from all
> three functions on a primary node, and code comments back up my thoughts.

Agreed.

> The problem is, what if the node is a standby which was promoted without
> restarting, or that had to perform crash recovery?
> 
> So during the time it's recovering the values in ` XLogCtl` are updated
> with recovery information, and once the recovery finishes, due to crash
> recovery reaching a consistent state, or a promotion of a standby
> happening, those values are not reset to startup defaults.
> 
> That's when you start seeing non-null values returned by
> `pg_last_wal_replay_lsn()`and `pg_last_xact_replay_timestamp()`.
> 
> Now, I don't know if we should call this a bug, or an undocumented
> anomaly. We could fix the bug by resetting the values from ` XLogCtl`
> after finishing recovery, or document that we might see non-NULL values
> in certain cases.

IMV, and not unlike other similar cases I've talked about on another
thread, these should be cleared when the system is promoted as they're
otherwise confusing and nonsensical.

Thanks,

Stephen

Attachments:

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

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

* Re: Non-null values of recovery functions after promote or crash of primary
  2019-10-05 11:43 Non-null values of recovery functions after promote or crash of primary Martín Marqués <martin@2ndquadrant.com>
  2019-10-08 18:03 ` Re: Non-null values of recovery functions after promote or crash of primary Stephen Frost <sfrost@snowman.net>
@ 2019-10-08 19:56   ` Martín Marqués <martin@2ndquadrant.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Martín Marqués @ 2019-10-08 19:56 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: pgsql-bugs@lists.postgresql.org, PostgreSQL-development <pgsql-hackers@postgresql.org>

Hi,

> IMV, and not unlike other similar cases I've talked about on another
> thread, these should be cleared when the system is promoted as they're
> otherwise confusing and nonsensical.

Keep in mind that this also happens when the server crashes and has to
perform crash recovery. In that case the server was always a primary.

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services





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


end of thread, other threads:[~2019-10-08 19:56 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-10-05 11:43 Non-null values of recovery functions after promote or crash of primary Martín Marqués <martin@2ndquadrant.com>
2019-10-08 18:03 ` Stephen Frost <sfrost@snowman.net>
2019-10-08 19:56   ` Martín Marqués <martin@2ndquadrant.com>

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