Install the whpg-diskquota package on each host in your WarehousePG cluster, as it doesn't ship as part of the WarehousePG server package.
Supported platforms
whpg-diskquota platform support differs by WarehousePG version:
| WarehousePG version | whpg-diskquota version | Architecture | Operating systems |
|---|---|---|---|
| 7 | 2.4.0 | amd64 | RHEL 8, 9 |
| 7 | 2.4.0 | ppc64le | RHEL 8, 9 |
| 6 | 2.3.x | amd64 | RHEL 7, 8, 9 |
whpg-diskquota 2.4.0 is the first release built for the ppc64le architecture.
WarehousePG 6 doesn't support database or cluster quotas, which require whpg-diskquota 2.4.0 and WarehousePG 7. See the release notes for the WarehousePG version and platforms each whpg-diskquota release targets.
Installing the package
Refer to Downloading and installing an extension for repository setup instructions. The package name is edb-whpg6-diskquota for WarehousePG 6, or edb-whpg7-diskquota for WarehousePG 7.
Registering whpg-diskquota for first use
After you install the package on every host, perform the following steps to configure whpg-diskquota for first use:
From the coordinator, create the
diskquotadatabase. The launcher uses this database to store the list of monitored databases and, sincewhpg-diskquota2.4, the cluster quota.createdb diskquota
Check for existing shared libraries:
gpconfig -s shared_preload_librariesUse the output of the previous command to enable
diskquota, along with any other shared libraries, and restart WarehousePG:gpconfig -c shared_preload_libraries -v '<other_libraries>, diskquota-2.4' gpstop -ar
gpconfig -c shared_preload_libraries -v '<other_libraries>, diskquota-2.3' gpstop -ar
Register the
diskquotaextension in each database where you want to enforce disk usage quotas. By default,whpg-diskquotacan monitor up to 50 databases. Raise that limit withdiskquota.max_monitored_databasesbefore you start the server, if you need to monitor more.CREATE EXTENSION diskquota;
If the database already has tables, run
diskquota.init_table_size_table()to record their current sizes. Until you do,whpg-diskquotastays inactive in that database. It reports the database's usage as 0 and doesn't enforce its quotas. In a database with many files, sizing can take some time. In an empty database, you can skip this step.SELECT diskquota.init_table_size_table();
Run it again if WarehousePG restarts after a crash, or after an operation such as
ALTER TABLESPACEorTRUNCATEthat changes a table'srelfilenode, sincewhpg-diskquotadoesn't lock a relation while computing its size and can record an incorrect size in either situation. In most cases you can ignore the difference, sincewhpg-diskquotaupdates the size the next time data is written to the table. To correct it right away, runinit_table_size_table()again, then restart WarehousePG, since the running worker only reloads table sizes at startup.
Verifying the installation
Confirm that diskquota is registered in the database, and check its status:
\dx
List of installed extensions Name | Version | Schema | Description -----------+---------+--------+------------------------------ diskquota | 2.4 | public | Disk Quota Main Program
SELECT * FROM diskquota.status();
name | status ------------------------+--------- soft limits | on hard limits | off current binary version | 2.4.0 current schema version | 2.4 (4 rows)
Upgrading whpg-diskquota
First, upgrade the whpg-diskquota package on every host. Refer to Upgrading an extension for downloading and distributing the new package. The package name is edb-whpg6-diskquota for WarehousePG 6, or edb-whpg7-diskquota for WarehousePG 7.
Then replace the diskquota-<version> shared library in shared_preload_libraries, restart WarehousePG, and update the extension in every database where you registered it:
Check for existing shared libraries:
gpconfig -s shared_preload_librariesUse the output of the previous command to replace the old
diskquotalibrary with the new one, keeping any other shared libraries, and restart WarehousePG. For example, to upgrade from 2.3 to 2.4:gpconfig -c shared_preload_libraries -v '<other_libraries>, diskquota-2.4' gpstop -ar
Update the extension in every database where you registered
diskquota:ALTER EXTENSION diskquota UPDATE TO '2.4';
whpg-diskquota pauses during the upgrade and resumes automatically once it completes. Your existing schema, role, and tablespace quotas continue to be enforced after the upgrade, and you can define database and cluster quotas once every database is on 2.4.
Downgrading from 2.4
Before downgrading to 2.3, remove the quotas that are new in 2.4, replace the shared library, and update the extension in every database where you registered it:
In every monitored database, delete the 2.4-only quota rows and clear the cluster quota, since a 2.3 worker can't read them and behaves unpredictably on refresh if any remain:
SELECT diskquota.prepare_downgrade();
Don't run
prepare_downgrade()inside an explicit transaction block, since it commits on its own and refuses to run in one. To cancel a prepared downgrade, runSELECT diskquota.init_table_size_table();.Point
shared_preload_librariesback atdiskquota-2.3and restart WarehousePG:gpconfig -c shared_preload_libraries -v '<other_libraries>, diskquota-2.3' gpstop -ar
Update the extension in every database where you registered
diskquota:ALTER EXTENSION diskquota UPDATE TO '2.3';
In each database, the command fails and rolls back if you didn't run
prepare_downgrade()there first, so an in-place downgrade can't leave 2.4-only quota rows behind by accident.Note
If you plan to restore a
pg_dumpbackup of a 2.4 database into a cluster runningwhpg-diskquota2.3, runprepare_downgrade()in the source database before you take the backup. Restoring an unprepared backup bypasses theALTER EXTENSIONcheck, and the 2.3 worker can't read the 2.4-only quota rows the backup carries.prepare_downgrade()also removes the source database's quota and the source cluster's cluster quota, so after the backup, runinit_table_size_table()in the source database and set those quotas again.
Uninstalling whpg-diskquota
Uninstall whpg-diskquota, whether from one database or from every database in the cluster.
If you're removing
whpg-diskquotafrom every database, remove the cluster quota first, from any one of them. It's stored once, in thediskquotadatabase, so it outlivesDROP EXTENSIONand would otherwise apply again the next time you create the extension:SELECT diskquota.set_cluster_quota('-1');
Pause
whpg-diskquotabefore you drop it from a database, to avoid a chance of deadlock:SELECT diskquota.pause(); DROP EXTENSION diskquota;
Dropping a monitored database
Drop the diskquota extension first from a database you need to drop. The database's whpg-diskquota worker keeps a connection open to it, so DROP DATABASE otherwise fails with database "sales" is being accessed by other users.
Pause and drop the extension in the database you want to remove. For example:
\c sales SELECT diskquota.pause(); DROP EXTENSION diskquota;
Connect to a different database and drop it:
\c postgres DROP DATABASE sales;