Re: Control your disk usage in PG: Introduction to Disk Quota Extension

From: Hubert Zhang <hzhang(at)pivotal(dot)io>
To: Haozhou Wang <hawang(at)pivotal(dot)io>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Subject: Re: Control your disk usage in PG: Introduction to Disk Quota Extension
Date: 2019-01-22 04:08:46
Message-ID: CAB0yrek4pbh-x7vYmKh70YRfbXhd7k1Ceqwhyy35jUYdYRrXAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > For this particular purpose, I don't immediately see why you need a
> > hook in both places. If ReadBuffer is called with P_NEW, aren't we
> > guaranteed to end up in smgrextend()?
> Yes, that's a bit awkward.

Hi Michael, we revisit the ReadBuffer hook and remove it in the latest
patch.
ReadBuffer hook is original used to do enforcement(e.g. out of diskquota
limit) when query is loading data.
We plan to put the enforcement work of running query to separate diskquota
worker process.
Let worker process to detect the backends to be cancelled and send SIGINT
to these backends.
So there is no need for ReadBuffer hook anymore.

Our patch currently only contains smgr related hooks to catch the file
change and get the Active Table list for diskquota extension.

Thanks Hubert.

On Mon, Jan 7, 2019 at 6:56 PM Haozhou Wang <hawang(at)pivotal(dot)io> wrote:

> Thanks very much for your comments.
>
> To the best of my knowledge, smgr is a layer that abstract the storage
> operations. Therefore, it is a good place to control or collect information
> the storage operations without touching the physical storage layer.
> Moreover, smgr is coming with actual disk IO operation (not consider the
> OS cache) for postgres. So we do not need to worry about the buffer
> management in postgres.
> It will make the purpose of hook is pure: a hook for actual disk IO.
>
> Regards,
> Haozhou
>
> On Wed, Dec 26, 2018 at 1:56 PM Michael Paquier <michael(at)paquier(dot)xyz>
> wrote:
>
>> On Wed, Nov 21, 2018 at 09:47:44AM -0500, Robert Haas wrote:
>> > +1 for adding some hooks to support this kind of thing, but I think
>> > the names you've chosen are not very good. The hook name should
>> > describe the place from which it is called, not the purpose for which
>> > one imagines that it will be used, because somebody else might imagine
>> > another use. Both BufferExtendCheckPerms_hook_type and
>> > SmgrStat_hook_type are imagining that they know what the hook does -
>> > CheckPerms in the first case and Stat in the second case.
>>
>> I personally don't mind making Postgres more pluggable, but I don't
>> think that we actually need the extra ones proposed here at the layer
>> of smgr, as smgr is already a layer designed to call an underlying set
>> of APIs able to extend, unlink, etc. depending on the storage type.
>>
>> > For this particular purpose, I don't immediately see why you need a
>> > hook in both places. If ReadBuffer is called with P_NEW, aren't we
>> > guaranteed to end up in smgrextend()?
>>
>> Yes, that's a bit awkward.
>> --
>> Michael
>
>

--
Thanks

Hubert Zhang

Attachment Content-Type Size
disk_quota_hooks_v3.patch application/octet-stream 4.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2019-01-22 04:10:00 Re: [HACKERS] PATCH: multivariate histograms and MCV lists
Previous Message Andreas Karlsson 2019-01-22 03:47:36 Re: Early WIP/PoC for inlining CTEs