pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix data loss when restarting the bulk_write facility
Date: Fri, 22 Nov 2024 14:51:10 +0000
Message-ID: <E1tEV02-0032PK-3M@gemulon.postgresql.org> (raw)

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@gmail.com>
Reported-By: Erik Nordström <erik@timescale.com>
Reviewed-by: Erik Nordström <erik@timescale.com>
Discussion: https://www.postgresql.org/message-id/CACAa4VJ%2BQY4pY7M0ECq29uGkrOygikYtao1UG9yCDFosxaps9g@mail.gma...

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(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1tEV02-0032PK-3M@gemulon.postgresql.org>
Permalink:  ../E1tEV02-0032PK-3M@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tEV02-0032PK-3M@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix data loss when restarting the bulk_write facility
  In-Reply-To: <E1tEV02-0032PK-3M@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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