Re: Getting total and free disk space from paths in PGDATA

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Getting total and free disk space from paths in PGDATA
Date: 2015-09-09 02:26:27
Message-ID: CAB7nPqTnCEp50UCNjsm9+Do8u6BAYLCgQcHEkSMj=jTj5CLYfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 9, 2015 at 6:13 AM, Kevin Grittner wrote:
> Michael Paquier wrote:
> When I was working with Wisconsin Courts we needed something like
> this, and wrote it. It has been used on hundreds of clusters,
> 24/7, for years. I see that the last publicly posted updated was
> in 2008, but it likely never needed changes after that. We used it
> on Windows and Linux. At the time, the community rather actively
> rejected incorporating it, but maybe in today's world of extensions
> it could be put on pgxn.org.

That's not surprising to see something similar, thanks for pointing it
out! I actually tried duckduckgoing/googling something similar but
even this thread did not show up. Something interesting about the
thread you pointed out is that statvfs is not that portable: OpenBSD
does not include it, and by looking around recent versions don't have
it as well. We could fallback to statfs though.

A major difference between what I got in mind though compared to what
this extension does is to not provide any information about the file
system, just the free and available space, the restrictions of
genfile.c for path strings applying as well. So this seems more
acceptable from the security POV. Currently, we can use pg_stat_file
combined with pg_ls_file to have an estimation of the total space used
by a path, but any credible use case would need to compare this size
with some output from a system call like df.
Regards,
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-09-09 03:17:38 Re: Getting total and free disk space from paths in PGDATA
Previous Message Steve Singer 2015-09-09 02:02:29 Re: snapshot too old, configured by time