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

From: Haozhou Wang <hawang(at)pivotal(dot)io>
To: pgsql-hackers(at)postgresql(dot)org
Cc: tomas(dot)vondra(at)2ndquadrant(dot)com
Subject: Re: Control your disk usage in PG: Introduction to Disk Quota Extension
Date: 2018-11-20 07:20:27
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

Hi all,

We prepared a patch that includes the hook points. And such hook points are
needed for disk quota extension.
There are two hooks.
One is SmgrStat_hook. It's used to perform ad-hoc logic in storage when
doing smgr create/extend/truncate in general. As for disk quota extension,
this hook is used to detect active tables(new created tables, tables
extending new blocks, or tables being truncated)
The other is BufferExtendCheckPerms_hook. It's used to perform ad-hoc logic
when buffer extend a new block. Since ReadBufferExtended is a hot function,
we call this hook only when blockNum == P_NEW. As for disk quota
extension, this hook is used to do query enforcement during the query is
loading data.

Any comments are appreciated.


On Wed, Nov 14, 2018 at 6:07 PM Hubert Zhang <hzhang(at)pivotal(dot)io> wrote:

> Thanks, Tomas,
> Yes, we want to add the hooks into postgres repo.
> But before that, we plan to firstly get some feedbacks from community
> about the diskquota extension implementation and usage?
> Later, we'll modify our license and submit the hooks into CF.
> Thanks
> Hubert
> On Wed, Nov 14, 2018 at 3:54 AM Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
> wrote:
>> On Tue, 2018-11-13 at 16:47 +0800, Hubert Zhang wrote:
>> > Hi all,
>> >
>> > We implement disk quota feature on Postgresql as an extension(link:
>> >,
>> > If you are interested, try and use it to limit the amount of disk
>> > space that
>> > a schema or a role can use in Postgresql.
>> > Any feedback or question are appreciated.
>> >
>> It's not clear to me what's the goal of this thread? I understand what
>> quotas are about, but are you sharing it because (a) it's a useful
>> extension, (b) you propose adding a couple of new hooks (and keep the
>> extension separate) or (c) you propose adding both the hooks and the
>> extension (into contrib)?
>> I assume it's either (b) and (c), in which case you should add it to
>> 2019-01 CF:
>> In either case, it might be useful to add a LICENSE to the github
>> repository, it's not clear what's the situation in this respect. That
>> probably matters especially for (b), because for (c) it'd end up with
>> PostgreSQL license automatically.
>> regards
>> --
>> Tomas Vondra
>> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
> --
> Thanks
> Hubert Zhang

Attachment Content-Type Size
disk_quota_hooks_v1.patch application/octet-stream 4.6 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Darafei Komяpa Praliaskouski 2018-11-20 07:23:25 Re: zheap: a new storage format for PostgreSQL
Previous Message Michael Paquier 2018-11-20 07:15:56 Re: typo fix