]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Free disk space for dropped relations on commit.
authorThomas Munro <tmunro@postgresql.org>
Tue, 1 Dec 2020 00:46:27 +0000 (13:46 +1300)
committerThomas Munro <tmunro@postgresql.org>
Tue, 1 Dec 2020 00:46:27 +0000 (13:46 +1300)
commitd5706ad7b70a03c53d06abff019d4cc56342ab09
treefb4998174d46ebc15bcbd10ac63bd831c8d434f1
parented9c9b033546129daf06d4aa013f5c0e22c5947d
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.patron@previnet.it>
Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>
Reviewed-by: Neil Chen <carpenter.nail.cz@gmail.com>
Reviewed-by: David Zhang <david.zhang@highgo.ca>
Discussion: https://postgr.es/m/16663-fe97ccf9932fc800%40postgresql.org
src/backend/storage/smgr/md.c