pgsql: Fix data loss when restarting the bulk_write facility

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix data loss when restarting the bulk_write facility
Date: 2024-11-22 14:51:10
Message-ID: E1tEV02-0032PK-3M@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix data loss when restarting the bulk_write facility

If a user started a bulk write operation on a fork with existing data
to append data in bulk, the bulk_write machinery would zero out all
previously written pages up to the last page written by the new
bulk_write operation.

This is not an issue for PostgreSQL itself, because we never use the
bulk_write facility on a non-empty fork. But there are use cases where
it makes sense. TimescaleDB extension is known to do that to merge
partitions, for example.

Backpatch to v17, where the bulk_write machinery was introduced.

Author: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Reported-By: Erik Nordström <erik(at)timescale(dot)com>
Reviewed-by: Erik Nordström <erik(at)timescale(dot)com>
Discussion: https://www.postgresql.org/message-id/CACAa4VJ%2BQY4pY7M0ECq29uGkrOygikYtao1UG9yCDFosxaps9g@mail.gmail.com

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9695835538c2c8e9cd0048028b8c85e1bbf5c79c

Modified Files
--------------
src/backend/storage/smgr/bulk_write.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2024-11-22 16:05:34 pgsql: Make the memory layout of Port struct independent of USE_OPENSSL
Previous Message Thomas Munro 2024-11-22 08:47:56 pgsql: Use auxv to check for CRC32 instructions on ARM.