pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Idle sessions keep deleted files open
2+ messages / 2 participants
[nested] [flat]

* Idle sessions keep deleted files open
@ 2020-03-29 22:49 Peter J. Holzer <hjp-pgsql@hjp.at>
  2020-03-29 23:22 ` Re: Idle sessions keep deleted files open Andres Freund <andres@anarazel.de>
  0 siblings, 1 reply; 2+ messages in thread

From: Peter J. Holzer @ 2020-03-29 22:49 UTC (permalink / raw)
  To: pgsql-general

I noticed this with PostgreSQL 11.7 on Linux:

I did a «vacuum full» on a table which had become quite bloated (size
before the vacuum: 392 GB, after: 291 GB). I expected the disk usage to
increase as the new table was written and then drop sharply after the
vacuum was finished.

However, that didn't happen. While usage increased by about 300 GB
during the vacuum, it stayed the same afterwards (as reported by «df»).

However, «du» reported about 400 GB less than «df». So apparently, files
had been unlinked but were still in use by some process.

«lsof» confirmed this: There were some idle sessions which were keeping
the files open. As soon as I got those sessions to execute some request,
they closed the files, causing the disk space to be freed.

I think I noticed that before when dropping tables, but didn't draw the
right conclusion at the time.

So, if you are reorganizing large tables, keep an eye on idle sessions -
they may keep deleted files around for quite some time.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Idle sessions keep deleted files open
  2020-03-29 22:49 Idle sessions keep deleted files open Peter J. Holzer <hjp-pgsql@hjp.at>
@ 2020-03-29 23:22 ` Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Andres Freund @ 2020-03-29 23:22 UTC (permalink / raw)
  To: Peter J. Holzer <hjp-pgsql@hjp.at>; +Cc: pgsql-general

Hi,

On 2020-03-30 00:49:13 +0200, Peter J. Holzer wrote:
> I noticed this with PostgreSQL 11.7 on Linux:
> 
> I did a «vacuum full» on a table which had become quite bloated (size
> before the vacuum: 392 GB, after: 291 GB). I expected the disk usage to
> increase as the new table was written and then drop sharply after the
> vacuum was finished.
> 
> However, that didn't happen. While usage increased by about 300 GB
> during the vacuum, it stayed the same afterwards (as reported by «df»).
> 
> However, «du» reported about 400 GB less than «df». So apparently, files
> had been unlinked but were still in use by some process.
> 
> «lsof» confirmed this: There were some idle sessions which were keeping
> the files open. As soon as I got those sessions to execute some request,
> they closed the files, causing the disk space to be freed.
> 
> I think I noticed that before when dropping tables, but didn't draw the
> right conclusion at the time.
> 
> So, if you are reorganizing large tables, keep an eye on idle sessions -
> they may keep deleted files around for quite some time.

I think this is partially related to
https://postgr.es/m/20181003223725.elcu3t44fpd4lm56%40alap3.anarazel.de

Greetings,

Andres Freund





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-03-29 23:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-29 22:49 Idle sessions keep deleted files open Peter J. Holzer <hjp-pgsql@hjp.at>
2020-03-29 23:22 ` Andres Freund <andres@anarazel.de>

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