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.
Fix bug: rejectmap entries should not be removed by other databases. …
…(#279) This commit fixed two bugs: - Previously, refresh_rejectmap() cleared all entries in rejectmap, including other databases' entries, which causes hardlimit can not to work correctly. - soft-limit rejectmap entries should not be added into disk_quota_reject_map on segments, otherwise, these entries may remain in segments and trigger the soft-limit incorrectly. Co-authored-by: Chen Mulong <[email protected]>
- Loading branch information
Showing
4 changed files
with
168 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
-- One db's rejectmap update should not impact on other db's rejectmap | ||
CREATE DATABASE tjmu1; | ||
CREATE DATABASE tjmu2; | ||
-- start_ignore | ||
\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null | ||
\! gpstop -u > /dev/null | ||
-- end_ignore | ||
\c tjmu1 | ||
CREATE EXTENSION diskquota; | ||
SELECT diskquota.set_schema_quota('public', '1MB'); | ||
set_schema_quota | ||
------------------ | ||
|
||
(1 row) | ||
|
||
CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); | ||
SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
|
||
-- Trigger hard limit to dispatch rejectmap for tjmu1 | ||
INSERT INTO b SELECT generate_series(1, 100000000); -- fail | ||
ERROR: schema's disk space quota exceeded with name: 2200 (seg1 127.0.0.1:6003 pid=3985762) | ||
-- NOTE: Pause to avoid tjmu1's worker clear the active table. Since the naptime is 0 on CI, this might be flaky. | ||
SELECT diskquota.pause(); | ||
pause | ||
------- | ||
|
||
(1 row) | ||
|
||
-- The rejectmap should contain entries with dbnode = 0 and dbnode = tjmu1_oid. count = 1 | ||
SELECT COUNT(DISTINCT r.dbnode) FROM (SELECT (diskquota.show_rejectmap()).* FROM gp_dist_random('gp_id')) as r where r.dbnode != 0; | ||
count | ||
------- | ||
1 | ||
(1 row) | ||
|
||
\c tjmu2 | ||
CREATE EXTENSION diskquota; | ||
SELECT diskquota.set_schema_quota('public', '1MB'); | ||
set_schema_quota | ||
------------------ | ||
|
||
(1 row) | ||
|
||
CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); | ||
SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
|
||
-- Trigger hard limit to dispatch rejectmap for tjmu2 | ||
INSERT INTO b SELECT generate_series(1, 100000000); -- fail | ||
ERROR: schema's disk space quota exceeded with name: 2200 (seg1 127.0.0.1:6003 pid=4001721) | ||
SELECT diskquota.wait_for_worker_new_epoch(); | ||
wait_for_worker_new_epoch | ||
--------------------------- | ||
t | ||
(1 row) | ||
|
||
SELECT diskquota.pause(); | ||
pause | ||
------- | ||
|
||
(1 row) | ||
|
||
--\c tjmu1 | ||
-- The rejectmap should contain entris with dbnode = 0 and dbnode = tjmu1_oid and tjmu2_oid. count = 2 | ||
-- The entries for tjmu1 should not be cleared | ||
SELECT COUNT(DISTINCT r.dbnode) FROM (SELECT (diskquota.show_rejectmap()).* FROM gp_dist_random('gp_id')) as r where r.dbnode != 0; | ||
count | ||
------- | ||
2 | ||
(1 row) | ||
|
||
-- start_ignore | ||
\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null | ||
\! gpstop -u > /dev/null | ||
-- end_ignore | ||
\c tjmu1 | ||
DROP EXTENSION diskquota; | ||
\c tjmu2 | ||
DROP EXTENSION diskquota; | ||
\c contrib_regression | ||
DROP DATABASE tjmu1; | ||
DROP DATABASE tjmu2; |
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,53 @@ | ||
-- One db's rejectmap update should not impact on other db's rejectmap | ||
CREATE DATABASE tjmu1; | ||
CREATE DATABASE tjmu2; | ||
|
||
-- start_ignore | ||
\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null | ||
-- increase the naptime to avoid active table gets cleared by tjmu1's worker | ||
\! gpconfig -c "diskquota.naptime" -v 1 > /dev/null | ||
\! gpstop -u > /dev/null | ||
-- end_ignore | ||
|
||
\c tjmu1 | ||
CREATE EXTENSION diskquota; | ||
SELECT diskquota.set_schema_quota('public', '1MB'); | ||
CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); | ||
SELECT diskquota.wait_for_worker_new_epoch(); | ||
-- Trigger hard limit to dispatch rejectmap for tjmu1 | ||
INSERT INTO b SELECT generate_series(1, 100000000); -- fail | ||
-- NOTE: Pause to avoid tjmu1's worker clear the active table. Since the naptime is 0 on CI, this might be flaky. | ||
SELECT diskquota.pause(); | ||
-- The rejectmap should contain entries with dbnode = 0 and dbnode = tjmu1_oid. count = 1 | ||
SELECT COUNT(DISTINCT r.dbnode) FROM (SELECT (diskquota.show_rejectmap()).* FROM gp_dist_random('gp_id')) as r where r.dbnode != 0; | ||
|
||
\c tjmu2 | ||
CREATE EXTENSION diskquota; | ||
SELECT diskquota.set_schema_quota('public', '1MB'); | ||
CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); | ||
SELECT diskquota.wait_for_worker_new_epoch(); | ||
-- Trigger hard limit to dispatch rejectmap for tjmu2 | ||
INSERT INTO b SELECT generate_series(1, 100000000); -- fail | ||
SELECT diskquota.wait_for_worker_new_epoch(); | ||
SELECT diskquota.pause(); | ||
|
||
--\c tjmu1 | ||
-- The rejectmap should contain entris with dbnode = 0 and dbnode = tjmu1_oid and tjmu2_oid. count = 2 | ||
-- The entries for tjmu1 should not be cleared | ||
SELECT COUNT(DISTINCT r.dbnode) FROM (SELECT (diskquota.show_rejectmap()).* FROM gp_dist_random('gp_id')) as r where r.dbnode != 0; | ||
|
||
-- start_ignore | ||
\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null | ||
\! gpconfig -c "diskquota.naptime" -v 0 > /dev/null | ||
\! gpstop -u > /dev/null | ||
-- end_ignore | ||
|
||
\c tjmu1 | ||
DROP EXTENSION diskquota; | ||
\c tjmu2 | ||
DROP EXTENSION diskquota; | ||
|
||
\c contrib_regression | ||
DROP DATABASE tjmu1; | ||
DROP DATABASE tjmu2; | ||
|