pgsql: Free disk space for dropped relations on commit.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Free disk space for dropped relations on commit.
Date: 2020-12-01 02:23:17
Message-ID: E1kjvK1-00074m-LN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Free disk space for dropped relations on commit.

When committing a transaction that dropped a relation, we previously
truncated only the first segment file to free up disk space (the one
that won't be unlinked until the next checkpoint).

Truncate higher numbered segments too, even though we unlink them on
commit. This frees the disk space immediately, even if other backends
have open file descriptors and might take a long time to get around to
handling shared invalidation events and closing them. Also extend the
same behavior to the first segment, in recovery.

Back-patch to all supported releases.

Bug: #16663
Reported-by: Denis Patron <denis(dot)patron(at)previnet(dot)it>
Reviewed-by: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>
Reviewed-by: Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>
Reviewed-by: David Zhang <david(dot)zhang(at)highgo(dot)ca>
Discussion: https://postgr.es/m/16663-fe97ccf9932fc800%40postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d0bbe212209924e664a783a767e827df5b5c08d3

Modified Files
--------------
src/backend/storage/smgr/md.c | 89 +++++++++++++++++++++++++++++++------------
1 file changed, 65 insertions(+), 24 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2020-12-01 02:23:28 pgsql: Free disk space for dropped relations on commit.
Previous Message Thomas Munro 2020-12-01 02:23:05 pgsql: Free disk space for dropped relations on commit.