BUG #14999: pg_rewind corrupts control file global/pg_control

The Post Office <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@postgresql.org
Cc: office@tiptop-labs.com
Date: 2018-01-04T20:06:33Z
Lists: pgsql-bugs, pgsql-hackers
The following bug has been logged on the website:

Bug reference:      14999
Logged by:          Christian H.
Email address:      office@tiptop-labs.com
PostgreSQL version: 10.1
Operating system:   e.g. Debian Buster
Description:        

I have encountered a bug in PostgreSQL 10.1: when the target directory for
pg_rewind contains a read-only file (e.g. server.key), pg_rewind exits with
"could not open target file" (legitimate) and corrupts the control file
global/pg_control to size 0 (bug). From now on, pg_rewind always exits with
"unexpected control file size 0, expected 8192" and a restore from
pg_basebackup is needed.

A patch for branch REL_10_STABLE of repository
https://github.com/postgres/postgres, a README, and Dockerfiles for
demonstrating both bug and patch are available from
https://github.com/tiptop-labs/postgres-patches .

Commits

  1. Add note in pg_rewind documentation about read-only files