forked from greenplum-db/diskquota-archive
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invalidate diskquota.table_size entries during startup
Diskquota calculates sizes and stores information in the diskquota.table_size table periodically with a pause in diskquota.naptime, 2 seconds by default. If we restart the cluster during this pause, then diskquota will lose all changes that have occurred since the last save to the diskquota.table_size table. We could create temporary tables, wait when it will be flushed to diskquota.table_size table, restart the cluster, and diskquota would remember the information about the temporary tables. Or we could delete the tables, restart the cluster, and again diskquota will remember information about the deleted tables. This happens because at the start of the cluster, diskquota remembers all the information written to the diskquota.table_size table, but does not check that some tables may have already been deleted. As a solution, we invalidate diskquota.table_size during diskquota worker start in addition to pg_class validation.
- Loading branch information
Showing
8 changed files
with
155 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
1: CREATE SCHEMA dropped_schema; | ||
CREATE | ||
1: SET search_path TO dropped_schema; | ||
SET | ||
1: SELECT diskquota.set_schema_quota('dropped_schema', '1 MB'); | ||
set_schema_quota | ||
------------------ | ||
|
||
(1 row) | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
1: CREATE TABLE dropped_table(id int) DISTRIBUTED BY (id); | ||
CREATE | ||
1: INSERT INTO dropped_table SELECT generate_series(1, 100000); | ||
INSERT 100000 | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
1: DROP TABLE dropped_table; | ||
DROP | ||
1q: ... <quitting> | ||
|
||
!\retcode gpstop -afr; | ||
-- start_ignore | ||
-- end_ignore | ||
(exited with code 0) | ||
|
||
1: SELECT pg_table_size('dropped_table'::regclass::oid) size; | ||
ERROR: relation "dropped_table" does not exist | ||
LINE 1: SELECT pg_table_size('dropped_table'::regclass::oid) size; | ||
^ | ||
1: SELECT size FROM diskquota.table_size WHERE NOT EXISTS (SELECT 1 FROM pg_class WHERE tableid = oid) AND segid = -1; | ||
size | ||
------ | ||
(0 rows) | ||
1: DROP SCHEMA dropped_schema CASCADE; | ||
DROP | ||
1q: ... <quitting> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
1: CREATE SCHEMA temporary_schema; | ||
CREATE | ||
1: SET search_path TO temporary_schema; | ||
SET | ||
1: SELECT diskquota.set_schema_quota('temporary_schema', '1 MB'); | ||
set_schema_quota | ||
------------------ | ||
|
||
(1 row) | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
1: CREATE TEMPORARY TABLE temporary_table(id int) DISTRIBUTED BY (id); | ||
CREATE | ||
1: INSERT INTO temporary_table SELECT generate_series(1, 100000); | ||
INSERT 100000 | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
1q: ... <quitting> | ||
|
||
!\retcode gpstop -afr; | ||
-- start_ignore | ||
-- end_ignore | ||
(exited with code 0) | ||
|
||
1: SELECT pg_table_size('temporary_table'::regclass::oid) size; | ||
ERROR: relation "temporary_table" does not exist | ||
LINE 1: SELECT pg_table_size('temporary_table'::regclass::oid) size; | ||
^ | ||
1: SELECT size FROM diskquota.table_size WHERE NOT EXISTS (SELECT 1 FROM pg_class WHERE tableid = oid) AND segid = -1; | ||
size | ||
------ | ||
(0 rows) | ||
1: DROP SCHEMA temporary_schema CASCADE; | ||
DROP | ||
1q: ... <quitting> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
1: CREATE SCHEMA dropped_schema; | ||
1: SET search_path TO dropped_schema; | ||
1: SELECT diskquota.set_schema_quota('dropped_schema', '1 MB'); | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
1: CREATE TABLE dropped_table(id int) DISTRIBUTED BY (id); | ||
1: INSERT INTO dropped_table SELECT generate_series(1, 100000); | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
1: DROP TABLE dropped_table; | ||
1q: | ||
|
||
!\retcode gpstop -afr; | ||
|
||
1: SELECT pg_table_size('dropped_table'::regclass::oid) size; | ||
1: SELECT size FROM diskquota.table_size WHERE NOT EXISTS (SELECT 1 FROM pg_class WHERE tableid = oid) AND segid = -1; | ||
1: DROP SCHEMA dropped_schema CASCADE; | ||
1q: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
1: CREATE SCHEMA temporary_schema; | ||
1: SET search_path TO temporary_schema; | ||
1: SELECT diskquota.set_schema_quota('temporary_schema', '1 MB'); | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
1: CREATE TEMPORARY TABLE temporary_table(id int) DISTRIBUTED BY (id); | ||
1: INSERT INTO temporary_table SELECT generate_series(1, 100000); | ||
1: SELECT diskquota.wait_for_worker_new_epoch(); | ||
1q: | ||
|
||
!\retcode gpstop -afr; | ||
|
||
1: SELECT pg_table_size('temporary_table'::regclass::oid) size; | ||
1: SELECT size FROM diskquota.table_size WHERE NOT EXISTS (SELECT 1 FROM pg_class WHERE tableid = oid) AND segid = -1; | ||
1: DROP SCHEMA temporary_schema CASCADE; | ||
1q: |