pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: pg_rewind: Fix determining TLI when server was just promoted.
2+ messages / 2 participants
[nested] [flat]

* pgsql: pg_rewind: Fix determining TLI when server was just promoted.
@ 2023-02-23 13:40 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  2023-02-27 16:57 ` Re: pgsql: pg_rewind: Fix determining TLI when server was just promoted. Robert Haas <robertmhaas@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Heikki Linnakangas @ 2023-02-23 13:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

pg_rewind: Fix determining TLI when server was just promoted.

If the source server was just promoted, and it hasn't written the
checkpoint record yet, pg_rewind considered the server to be still on
the old timeline. Because of that, it would claim incorrectly that no
rewind is required. Fix that by looking at minRecoveryPointTLI in the
control file in addition to the ThisTimeLineID on the checkpoint.

This has been a known issue since forever, and we had worked around it
in the regression tests by issuing a checkpoint after each promotion,
before running pg_rewind. But that was always quite hacky, so better
to fix this properly. This doesn't add any new tests for this, but
removes the previously-added workarounds from the existing tests, so
that they should occasionally hit this codepath again.

This is arguably a bug fix, but don't backpatch because we haven't
really treated it as a bug so far. Also, the patch didn't apply
cleanly to v13 and below. I'm sure sure it could be made to work on
v13, but doesn't seem worth the risk and effort.

Reviewed-by: Kyotaro Horiguchi, Ibrar Ahmed, Aleksander Alekseev
Discussion: https://www.postgresql.org/message-id/9f568c97-87fe-a716-bd39-65299b8a60f4%40iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/009eeee746825090ec7194321a3db4b298d6571e

Modified Files
--------------
src/bin/pg_rewind/pg_rewind.c                 | 105 ++++++++++++++++----------
src/bin/pg_rewind/t/007_standby_source.pl     |   1 -
src/bin/pg_rewind/t/008_min_recovery_point.pl |   9 ---
src/bin/pg_rewind/t/RewindTest.pm             |   8 --
4 files changed, 64 insertions(+), 59 deletions(-)



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

* Re: pgsql: pg_rewind: Fix determining TLI when server was just promoted.
  2023-02-23 13:40 pgsql: pg_rewind: Fix determining TLI when server was just promoted. Heikki Linnakangas <heikki.linnakangas@iki.fi>
@ 2023-02-27 16:57 ` Robert Haas <robertmhaas@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Robert Haas @ 2023-02-27 16:57 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@iki.fi>; +Cc: pgsql-hackers

On Thu, Feb 23, 2023 at 8:40 AM Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:
> This is arguably a bug fix, but don't backpatch because we haven't
> really treated it as a bug so far.

I guess I'm having trouble understanding why this is only arguably a
bug fix. Seems like flat-out wrong behavior.

-- 
Robert Haas
EDB: http://www.enterprisedb.com





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


end of thread, other threads:[~2023-02-27 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 13:40 pgsql: pg_rewind: Fix determining TLI when server was just promoted. Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-02-27 16:57 ` Robert Haas <robertmhaas@gmail.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