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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix data-corruption hazard in WAL-logged CREATE DATABASE.
Date: 2022-08-06 15:50:50
Message-ID: E1oKM4g-000axS-DL@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/692df425b6883dd3edcc15bb984415ef349fafb1

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-08-06 17:32:38 pgsql: Fix function-defined-but-not-used warning.
Previous Message Andres Freund 2022-08-06 15:44:40 pgsql: Simplify gettimeofday() fallback logic.