Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADBDEV-4266: Diskquota stops working after removing any extension #25

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/gp_activetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,14 @@ object_access_hook_QuotaStmt(ObjectAccessType access, Oid classId, Oid objectId,
{
if (prev_object_access_hook) (*prev_object_access_hook)(access, classId, objectId, subId, arg);

// if is 'drop extension diskquota'
/* if is 'drop extension diskquota' */
if (classId == ExtensionRelationId && access == OAT_DROP)
{
if (get_extension_oid("diskquota", true) == objectId)
{
invalidate_database_rejectmap(MyDatabaseId);
diskquota_stop_worker();
}

diskquota_stop_worker();
return;
}

Expand Down
1 change: 1 addition & 0 deletions tests/regress/diskquota_schedule
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ test: test_tablespace_diff_schema
test: test_worker_schedule
test: test_worker_schedule_exception
test: test_dbname_encoding
test: test_drop_any_extension
test: test_drop_extension
test: reset_config
34 changes: 34 additions & 0 deletions tests/regress/expected/test_drop_any_extension.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE DATABASE test_drop_db;
\c test_drop_db
CREATE EXTENSION diskquota;
CREATE EXTENSION gp_inject_fault;
SELECT diskquota.init_table_size_table();
init_table_size_table
-----------------------

(1 row)

SELECT diskquota.set_schema_quota(current_schema, '1MB');
set_schema_quota
------------------

(1 row)

CREATE TABLE t(i int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
DROP EXTENSION gp_inject_fault;
-- expect success
INSERT INTO t SELECT generate_series(1, 100000);
SELECT diskquota.wait_for_worker_new_epoch();
wait_for_worker_new_epoch
---------------------------
t
(1 row)

-- expect fail
INSERT INTO t SELECT generate_series(1, 100000);
ERROR: schema's disk space quota exceeded with name: public
DROP EXTENSION diskquota;
\c contrib_regression
DROP DATABASE test_drop_db;
23 changes: 23 additions & 0 deletions tests/regress/sql/test_drop_any_extension.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE DATABASE test_drop_db;

\c test_drop_db

CREATE EXTENSION diskquota;
CREATE EXTENSION gp_inject_fault;
SELECT diskquota.init_table_size_table();

SELECT diskquota.set_schema_quota(current_schema, '1MB');
CREATE TABLE t(i int);

DROP EXTENSION gp_inject_fault;

-- expect success
INSERT INTO t SELECT generate_series(1, 100000);
SELECT diskquota.wait_for_worker_new_epoch();
-- expect fail
INSERT INTO t SELECT generate_series(1, 100000);

DROP EXTENSION diskquota;

\c contrib_regression
DROP DATABASE test_drop_db;
Loading