Fix data-corruption hazard in WAL-logged CREATE DATABASE.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 692df425b6883dd3edcc15bb984415ef349fafb1
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2022-08-06T15:50:34Z
Releases: 16.0
Fix data-corruption hazard in WAL-logged CREATE DATABASE.

RelationCopyStorageUsingBuffer thought it could skip copying
empty pages, but of course that does not work at all, because
subsequent blocks will be out of place.

Also fix it to acquire share lock on the source buffer.  It *might*
be safe to not do that, but it's not very certain, and I don't think
this code deserves any benefit of the doubt.

Dilip Kumar, per complaint from me

Discussion: https://postgr.es/m/3679800.1659654066@sss.pgh.pa.us

Files

PathChange+/−
src/backend/storage/buffer/bufmgr.c modified +3 −7

Discussion