From 10606b37d801f3dba5f4c6a029b0adf0ddeff7bb Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Fri, 3 Feb 2023 10:57:17 +0800 Subject: [PATCH 01/31] Format code by clang-format. (#296) --- diskquota.c | 16 +++++++--------- diskquota_utility.c | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/diskquota.c b/diskquota.c index 4581a29e..aa24b6cd 100644 --- a/diskquota.c +++ b/diskquota.c @@ -909,7 +909,8 @@ init_database_list(void) if (ret != SPI_OK_CONNECT) { int saved_errno = errno; - ereport(ERROR, (errmsg("[diskquota launcher] SPI connect error, reason: %s, return code: %d.", strerror(saved_errno), ret))); + ereport(ERROR, (errmsg("[diskquota launcher] SPI connect error, reason: %s, return code: %d.", + strerror(saved_errno), ret))); } ret = SPI_execute("select dbid from diskquota_namespace.database_list;", true, 0); if (ret != SPI_OK_SELECT) @@ -917,8 +918,7 @@ init_database_list(void) int saved_errno = errno; ereport(ERROR, (errmsg("[diskquota launcher] 'select diskquota_namespace.database_list', reason: %s, return code: %d.", - strerror(saved_errno), - ret))); + strerror(saved_errno), ret))); } tupdesc = SPI_tuptable->tupdesc; #if GP_VERSION_NUM < 70000 @@ -1234,8 +1234,7 @@ add_dbid_to_database_list(Oid dbid) int saved_errno = errno; ereport(ERROR, (errmsg("[diskquota launcher] error occured while checking database_list, " " code: %d, reason: %s.", - ret, - strerror(saved_errno)))); + ret, strerror(saved_errno)))); } if (SPI_processed == 1) @@ -1254,8 +1253,7 @@ add_dbid_to_database_list(Oid dbid) int saved_errno = errno; ereport(ERROR, (errmsg("[diskquota launcher] error occured while updating database_list, " " code: %d, reason: %s.", - ret, - strerror(saved_errno)))); + ret, strerror(saved_errno)))); } return; @@ -1282,8 +1280,8 @@ del_dbid_from_database_list(Oid dbid) if (ret != SPI_OK_DELETE) { int saved_errno = errno; - ereport(ERROR, - (errmsg("[diskquota launcher] del_dbid_from_database_list: reason: %s, ret_code: %d.", strerror(saved_errno), ret))); + ereport(ERROR, (errmsg("[diskquota launcher] del_dbid_from_database_list: reason: %s, ret_code: %d.", + strerror(saved_errno), ret))); } } diff --git a/diskquota_utility.c b/diskquota_utility.c index 6e55ee3c..da9bc080 100644 --- a/diskquota_utility.c +++ b/diskquota_utility.c @@ -1364,7 +1364,8 @@ relation_file_stat(int segno, void *ctx) if (errno != ENOENT) { int saved_errno = errno; - ereport(WARNING, (errcode_for_file_access(), errmsg("[diskquota] could not stat file %s: %s", file_path, strerror(saved_errno)))); + ereport(WARNING, (errcode_for_file_access(), + errmsg("[diskquota] could not stat file %s: %s", file_path, strerror(saved_errno)))); } return false; } From 54a273e85426885db4e9f55c58a1638d69c3b543 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Fri, 3 Feb 2023 12:10:26 +0800 Subject: [PATCH 02/31] Add command to compile isolation2. (#297) Isolation2 compilation command is removed by #285. We add it into Regress.cmake in this commit. Co-authored-by: Xing Guo higuoxing@gmail.com --- cmake/Regress.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/Regress.cmake b/cmake/Regress.cmake index 6d91c760..b265eb7f 100644 --- a/cmake/Regress.cmake +++ b/cmake/Regress.cmake @@ -43,6 +43,9 @@ function(_PGIsolation2Target_Add working_DIR) add_custom_target( pg_isolation2_regress + COMMAND + make -C ${PG_SRC_DIR}/src/test/isolation2 install + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PG_SRC_DIR}/src/test/isolation2/sql_isolation_testcase.py ${working_DIR} ) From fa269a3ac25d852eaae7cee4ea0cda884bec9e57 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Fri, 3 Feb 2023 15:49:39 +0800 Subject: [PATCH 03/31] Fix flaky test (#294) - Fix flaky test test_ctas_before_set_quota. pg_type will be an active table after `CREATE TABLE`. It does not affect the function of diskquota but makes the test results unstable. In fact, we do not care about the table size of the system catalog table. So we simply skip the active table oid of these tables. - Fix test_vacuum/test_truncate. gp_wait_until_triggered_fault should be called after gp_inject_fault_infinite with suspend flag. Co-authored-by: Xing Guo Co-authored-by: Xiaoran Wang --- gp_activetable.c | 7 ++++++- tests/isolation2/expected/test_truncate.out | 7 +++++++ tests/isolation2/expected/test_vacuum.out | 7 +++++++ tests/isolation2/expected7/test_truncate.out | 7 +++++++ tests/isolation2/expected7/test_vacuum.out | 7 +++++++ tests/isolation2/sql/test_truncate.sql | 2 ++ tests/isolation2/sql/test_vacuum.sql | 2 ++ 7 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gp_activetable.c b/gp_activetable.c index 73732e67..8caeccf8 100644 --- a/gp_activetable.c +++ b/gp_activetable.c @@ -805,7 +805,12 @@ get_active_tables_oid(void) rnode.spcNode = active_table_file_entry->tablespaceoid; relOid = get_relid_by_relfilenode(rnode); - if (relOid != InvalidOid) + /* skip system catalog tables */ + if (relOid < FirstNormalObjectId) + { + hash_search(local_active_table_file_map, active_table_file_entry, HASH_REMOVE, NULL); + } + else if (relOid != InvalidOid) { prelid = get_primary_table_oid(relOid, true); active_table_entry = hash_search(local_active_table_stats_map, &prelid, HASH_ENTER, &found); diff --git a/tests/isolation2/expected/test_truncate.out b/tests/isolation2/expected/test_truncate.out index d176b404..4964f6ec 100644 --- a/tests/isolation2/expected/test_truncate.out +++ b/tests/isolation2/expected/test_truncate.out @@ -39,6 +39,13 @@ SELECT diskquota.wait_for_worker_new_epoch(); t (1 row) 1&: TRUNCATE dummy_t1; +SELECT gp_wait_until_triggered_fault('diskquota_after_smgrcreate', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; + gp_wait_until_triggered_fault +------------------------------- + Success: + Success: + Success: +(3 rows) -- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch diff --git a/tests/isolation2/expected/test_vacuum.out b/tests/isolation2/expected/test_vacuum.out index 47eb944d..eb437932 100644 --- a/tests/isolation2/expected/test_vacuum.out +++ b/tests/isolation2/expected/test_vacuum.out @@ -52,6 +52,13 @@ SELECT diskquota.wait_for_worker_new_epoch(); t (1 row) 1&: VACUUM FULL dummy_t1; +SELECT gp_wait_until_triggered_fault('object_access_post_alter', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; + gp_wait_until_triggered_fault +------------------------------- + Success: + Success: + Success: +(3 rows) -- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch diff --git a/tests/isolation2/expected7/test_truncate.out b/tests/isolation2/expected7/test_truncate.out index d176b404..4964f6ec 100644 --- a/tests/isolation2/expected7/test_truncate.out +++ b/tests/isolation2/expected7/test_truncate.out @@ -39,6 +39,13 @@ SELECT diskquota.wait_for_worker_new_epoch(); t (1 row) 1&: TRUNCATE dummy_t1; +SELECT gp_wait_until_triggered_fault('diskquota_after_smgrcreate', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; + gp_wait_until_triggered_fault +------------------------------- + Success: + Success: + Success: +(3 rows) -- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch diff --git a/tests/isolation2/expected7/test_vacuum.out b/tests/isolation2/expected7/test_vacuum.out index 47eb944d..eb437932 100644 --- a/tests/isolation2/expected7/test_vacuum.out +++ b/tests/isolation2/expected7/test_vacuum.out @@ -52,6 +52,13 @@ SELECT diskquota.wait_for_worker_new_epoch(); t (1 row) 1&: VACUUM FULL dummy_t1; +SELECT gp_wait_until_triggered_fault('object_access_post_alter', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; + gp_wait_until_triggered_fault +------------------------------- + Success: + Success: + Success: +(3 rows) -- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch diff --git a/tests/isolation2/sql/test_truncate.sql b/tests/isolation2/sql/test_truncate.sql index 5bce3320..538b6318 100644 --- a/tests/isolation2/sql/test_truncate.sql +++ b/tests/isolation2/sql/test_truncate.sql @@ -14,6 +14,8 @@ SELECT gp_inject_fault_infinite('diskquota_after_smgrcreate', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; SELECT diskquota.wait_for_worker_new_epoch(); 1&: TRUNCATE dummy_t1; +SELECT gp_wait_until_triggered_fault('diskquota_after_smgrcreate', 1, dbid) + FROM gp_segment_configuration WHERE role='p' AND content<>-1; -- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. SELECT diskquota.wait_for_worker_new_epoch(); SELECT gp_inject_fault_infinite('diskquota_after_smgrcreate', 'reset', dbid) diff --git a/tests/isolation2/sql/test_vacuum.sql b/tests/isolation2/sql/test_vacuum.sql index cf46bb40..4125ac5f 100644 --- a/tests/isolation2/sql/test_vacuum.sql +++ b/tests/isolation2/sql/test_vacuum.sql @@ -26,6 +26,8 @@ SELECT gp_inject_fault_infinite('object_access_post_alter', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; SELECT diskquota.wait_for_worker_new_epoch(); 1&: VACUUM FULL dummy_t1; +SELECT gp_wait_until_triggered_fault('object_access_post_alter', 1, dbid) + FROM gp_segment_configuration WHERE role='p' AND content<>-1; -- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. SELECT diskquota.wait_for_worker_new_epoch(); SELECT gp_inject_fault_infinite('object_access_post_alter', 'reset', dbid) From 9ae2e82156c9fc366e5873d98012229822cccc6c Mon Sep 17 00:00:00 2001 From: Xiaoran Wang Date: Mon, 6 Feb 2023 09:07:44 +0800 Subject: [PATCH 04/31] Fix flaky test test_rejectmap_mul_db (#295) When creating a new table, pg_type will be in active tables. Filter the system catalog table. And remove pause in the test. --- tests/regress/expected/test_rejectmap_mul_db.out | 15 +-------------- tests/regress/expected7/test_rejectmap_mul_db.out | 15 +-------------- tests/regress/sql/test_rejectmap_mul_db.sql | 3 --- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/tests/regress/expected/test_rejectmap_mul_db.out b/tests/regress/expected/test_rejectmap_mul_db.out index 40c43ae3..78a10aad 100644 --- a/tests/regress/expected/test_rejectmap_mul_db.out +++ b/tests/regress/expected/test_rejectmap_mul_db.out @@ -22,14 +22,7 @@ SELECT diskquota.wait_for_worker_new_epoch(); -- 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) - +ERROR: schema's disk space quota exceeded with name: 2200 (seg1 127.0.0.1:8003 pid=43782) -- 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 @@ -61,12 +54,6 @@ SELECT diskquota.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 diff --git a/tests/regress/expected7/test_rejectmap_mul_db.out b/tests/regress/expected7/test_rejectmap_mul_db.out index ed2edc8d..89142d8b 100644 --- a/tests/regress/expected7/test_rejectmap_mul_db.out +++ b/tests/regress/expected7/test_rejectmap_mul_db.out @@ -24,14 +24,7 @@ SELECT diskquota.wait_for_worker_new_epoch(); -- 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:7003 pid=1961462) --- 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) - +ERROR: schema's disk space quota exceeded with name: 2200 (seg1 127.0.0.1:8003 pid=43782) -- 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 @@ -63,12 +56,6 @@ SELECT diskquota.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 diff --git a/tests/regress/sql/test_rejectmap_mul_db.sql b/tests/regress/sql/test_rejectmap_mul_db.sql index 3b2fd734..57fd16db 100644 --- a/tests/regress/sql/test_rejectmap_mul_db.sql +++ b/tests/regress/sql/test_rejectmap_mul_db.sql @@ -16,8 +16,6 @@ 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; @@ -29,7 +27,6 @@ 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 From bfe7bad2b6d082dcc1ed36681ff7685545f7a507 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Tue, 7 Feb 2023 15:23:17 +0800 Subject: [PATCH 05/31] Fix bug (#298) Fix the following bugs: - Judgement condition for update_relation_cache should be `&&`, instead of `||` - The lock for relation_open/relation_close should be AccessShareLock for gpdb7. - For `truncate table`, we cannot get the table's oid by new relfilenode immediately after `file_create_hook` is finished. So we should keep the relfilenode in active_table_file_map and wait for the next loop to calculate the correct size for this table. --- gp_activetable.c | 14 +++++++++++--- relation_cache.c | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gp_activetable.c b/gp_activetable.c index 8caeccf8..4cf2144f 100644 --- a/gp_activetable.c +++ b/gp_activetable.c @@ -268,12 +268,17 @@ report_relation_cache_helper(Oid relid) #if GP_VERSION_NUM < 70000 rel = diskquota_relation_open(relid, NoLock); #else - rel = diskquota_relation_open(relid, AccessShareLock); + rel = diskquota_relation_open(relid, AccessShareLock); #endif /* GP_VERSION_NUM */ - if (rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE || rel->rd_rel->relkind != RELKIND_COMPOSITE_TYPE || + if (rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE && rel->rd_rel->relkind != RELKIND_COMPOSITE_TYPE && rel->rd_rel->relkind != RELKIND_VIEW) update_relation_cache(relid); + +#if GP_VERSION_NUM < 70000 relation_close(rel, NoLock); +#else + relation_close(rel, AccessShareLock); +#endif /* GP_VERSION_NUM */ } /* @@ -805,12 +810,15 @@ get_active_tables_oid(void) rnode.spcNode = active_table_file_entry->tablespaceoid; relOid = get_relid_by_relfilenode(rnode); + /* If relfilenode is not prepared for some relation, just skip it. */ + if (!OidIsValid(relOid)) continue; + /* skip system catalog tables */ if (relOid < FirstNormalObjectId) { hash_search(local_active_table_file_map, active_table_file_entry, HASH_REMOVE, NULL); } - else if (relOid != InvalidOid) + else { prelid = get_primary_table_oid(relOid, true); active_table_entry = hash_search(local_active_table_stats_map, &prelid, HASH_ENTER, &found); diff --git a/relation_cache.c b/relation_cache.c index 224a9c37..352852e9 100644 --- a/relation_cache.c +++ b/relation_cache.c @@ -166,7 +166,11 @@ update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, Di relation_entry->primary_table_relid = relid; +#if GP_VERSION_NUM < 70000 relation_close(rel, NoLock); +#else + relation_close(rel, AccessShareLock); +#endif /* GP_VERSION_NUM */ } void @@ -235,7 +239,11 @@ parse_primary_table_oid(Oid relid, bool on_bgworker) } namespace = rel->rd_rel->relnamespace; memcpy(relname, rel->rd_rel->relname.data, NAMEDATALEN); +#if GP_VERSION_NUM < 70000 relation_close(rel, NoLock); +#else + relation_close(rel, AccessShareLock); +#endif /* GP_VERSION_NUM */ } parsed_oid = diskquota_parse_primary_table_oid(namespace, relname); From ff57e49ec2fcca564ce2f9848d83835e7bb053c4 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Wed, 8 Feb 2023 14:54:16 +0800 Subject: [PATCH 06/31] Enable upgrade test for CI (#299) Revert some modification from #285. - Add last_released_diskquota_bin back for CI. - Enable upgradecheck. - Add -DDISKQUOTA_LAST_RELEASE_PATH for cmake. --- CMakeLists.txt | 7 +------ concourse/pipeline/job_def.lib.yml | 14 +++++++------- concourse/scripts/build_diskquota.sh | 4 ++-- concourse/scripts/test_diskquota.sh | 2 +- concourse/tasks/build_diskquota.yml | 2 +- upgrade_test/CMakeLists.txt | 4 ++++ 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 514a7e7c..62111646 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,12 +170,7 @@ BuildInfo_Create(${build_info_PATH} # Add installcheck targets add_subdirectory(tests) -if(NOT DEFINED ENABLE_UPGRADE_TEST) - set(ENABLE_UPGRADE_TEST ON) -endif() -if(ENABLE_UPGRADE_TEST) - add_subdirectory(upgrade_test) -endif() +add_subdirectory(upgrade_test) # NOTE: keep install part at the end of file, to overwrite previous binary install(PROGRAMS "cmake/install_gpdb_component" DESTINATION ".") diff --git a/concourse/pipeline/job_def.lib.yml b/concourse/pipeline/job_def.lib.yml index 130e89e3..7e39bbaa 100644 --- a/concourse/pipeline/job_def.lib.yml +++ b/concourse/pipeline/job_def.lib.yml @@ -15,7 +15,7 @@ res_build_image: centos6-gpdb6-image-build res_test_images: [centos6-gpdb6-image-test] res_gpdb_bin: #@ "bin_gpdb6_centos6" + ("" if release_build else "_debug") -#! res_diskquota_bin: bin_diskquota_gpdb6_rhel6 +res_diskquota_bin: bin_diskquota_gpdb6_rhel6 res_intermediates_bin: #@ inter_bin_name("bin_diskquota_gpdb6_rhel6_intermediates", release_build) release_bin: bin_diskquota_gpdb6_rhel6_release os: rhel6 @@ -28,7 +28,7 @@ build_type: #@ "Release" if release_build else "Debug" res_build_image: centos7-gpdb6-image-build res_test_images: [centos7-gpdb6-image-test] res_gpdb_bin: #@ "bin_gpdb6_centos7" + ("" if release_build else "_debug") -#! res_diskquota_bin: bin_diskquota_gpdb6_rhel7 +res_diskquota_bin: bin_diskquota_gpdb6_rhel7 res_intermediates_bin: #@ inter_bin_name("bin_diskquota_gpdb6_rhel7_intermediates", release_build) release_bin: bin_diskquota_gpdb6_rhel7_release os: rhel7 @@ -41,7 +41,7 @@ build_type: #@ "Release" if release_build else "Debug" res_build_image: rhel8-gpdb6-image-build res_test_images: [rhel8-gpdb6-image-test] res_gpdb_bin: #@ "bin_gpdb6_rhel8" + ("" if release_build else "_debug") -#! res_diskquota_bin: bin_diskquota_gpdb6_rhel8 +res_diskquota_bin: bin_diskquota_gpdb6_rhel8 res_intermediates_bin: #@ inter_bin_name("bin_diskquota_gpdb6_rhel8_intermediates", release_build) release_bin: bin_diskquota_gpdb6_rhel8_release os: rhel8 @@ -54,7 +54,7 @@ build_type: #@ "Release" if release_build else "Debug" res_build_image: ubuntu18-gpdb6-image-build res_test_images: [ubuntu18-gpdb6-image-test] res_gpdb_bin: #@ "bin_gpdb6_ubuntu18" + ("" if release_build else "_debug") -#! res_diskquota_bin: bin_diskquota_gpdb6_ubuntu18 +res_diskquota_bin: bin_diskquota_gpdb6_ubuntu18 res_intermediates_bin: #@ inter_bin_name("bin_diskquota_gpdb6_ubuntu18_intermediates", release_build) release_bin: bin_diskquota_gpdb6_ubuntu18_release os: ubuntu18.04 @@ -67,7 +67,7 @@ build_type: #@ "Release" if release_build else "Debug" res_build_image: rocky8-gpdb7-image-build res_test_images: [rocky8-gpdb7-image-test, rhel8-gpdb7-image-test] res_gpdb_bin: #@ "bin_gpdb7_rhel8" + ("" if release_build else "_debug") -#! res_diskquota_bin: bin_diskquota_gpdb7_rhel8 +res_diskquota_bin: bin_diskquota_gpdb7_rhel8 res_intermediates_bin: #@ inter_bin_name("bin_diskquota_gpdb7_rhel8_intermediates", release_build) release_bin: bin_diskquota_gpdb7_rhel8_release os: rhel8 @@ -228,8 +228,8 @@ plan: - get: #@ test_image #@ end - get: #@ conf["res_gpdb_bin"] - #! - get: last_released_diskquota_bin - #! resource: #@ conf["res_diskquota_bin"] + - get: last_released_diskquota_bin + resource: #@ conf["res_diskquota_bin"] - #@ _build_task(conf) #@ if conf["build_type"] != "Release": - #@ _test_task(conf) diff --git a/concourse/scripts/build_diskquota.sh b/concourse/scripts/build_diskquota.sh index 3ca3efbc..7b2ee30b 100755 --- a/concourse/scripts/build_diskquota.sh +++ b/concourse/scripts/build_diskquota.sh @@ -12,10 +12,10 @@ function pkg() { pushd /home/gpadmin/diskquota_artifacts local last_release_path - # last_release_path=$(readlink -e /home/gpadmin/last_released_diskquota_bin/diskquota-*.tar.gz) + last_release_path=$(readlink -eq /home/gpadmin/last_released_diskquota_bin/diskquota-*.tar.gz) cmake /home/gpadmin/diskquota_src \ + -DDISKQUOTA_LAST_RELEASE_PATH="${last_release_path}" \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" - # -DDISKQUOTA_LAST_RELEASE_PATH="${last_release_path}" \ cmake --build . --target create_artifact popd } diff --git a/concourse/scripts/test_diskquota.sh b/concourse/scripts/test_diskquota.sh index 12566032..87c48663 100755 --- a/concourse/scripts/test_diskquota.sh +++ b/concourse/scripts/test_diskquota.sh @@ -30,7 +30,7 @@ function _main() { # activate_standby # time cmake --build . --target installcheck # Run upgrade test (with standby master) - # time cmake --build . --target upgradecheck + time cmake --build . --target upgradecheck popd } diff --git a/concourse/tasks/build_diskquota.yml b/concourse/tasks/build_diskquota.yml index ba71054f..cacf0fb2 100644 --- a/concourse/tasks/build_diskquota.yml +++ b/concourse/tasks/build_diskquota.yml @@ -6,7 +6,7 @@ inputs: - name: diskquota_src - name: gpdb_src - name: bin_cmake - # - name: last_released_diskquota_bin + - name: last_released_diskquota_bin outputs: - name: diskquota_artifacts diff --git a/upgrade_test/CMakeLists.txt b/upgrade_test/CMakeLists.txt index 2750b1dd..1e3a2562 100644 --- a/upgrade_test/CMakeLists.txt +++ b/upgrade_test/CMakeLists.txt @@ -57,6 +57,10 @@ endforeach() # if DDL file modified, insure the last release file passed in if(DISKQUOTA_DDL_CHANGE_CHECK AND DISKQUOTA_DDL_MODIFIED AND NOT DEFINED DISKQUOTA_LAST_RELEASE_PATH) + message( + FATAL_ERROR + "DDL file modify detected, upgrade test is required. Add -DDISKQUOTA_LAST_RELEASE_PATH=//diskquota--_.tar.gz. And re-try the generation" + ) endif() # check if current version is compatible with the upgrade strategy From b2367939bc2ff24bb8959ab6990e86ac559e7ef7 Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Thu, 9 Feb 2023 13:32:26 +0800 Subject: [PATCH 07/31] Skip fault injector case for release build (#302) Due to the release build change for GP7, the fault injector doesn't work with the release build. So, all the tests were temporally disabled for release pipelines. Since we switched to use the `--disable-debug-extensions` gpdb build, the fault injector is not available for the release pipeline. - Add 'EXCLUDE_FAULT_INJECT_TEST' to Regress.cmake, so it will be smart enough to check if there are any fault injector case in the give tests set. Ignore them if so. - Skip the fault injector tests for the release pipeline. - Enable the CI test task for GP7. --- .editorconfig | 4 +++ cmake/Regress.cmake | 39 +++++++++++++++++++++++++++++- concourse/pipeline/job_def.lib.yml | 2 -- tests/CMakeLists.txt | 8 ++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 635d6f22..053c91fd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,3 +20,7 @@ indent_size = 4 indent_style = space indent_size = 2 +[cmake/**.cmake] +indent_style = space +indent_size = 4 + diff --git a/cmake/Regress.cmake b/cmake/Regress.cmake index b265eb7f..62d8807f 100644 --- a/cmake/Regress.cmake +++ b/cmake/Regress.cmake @@ -12,6 +12,7 @@ # [REGRESS_OPTS ...] # [REGRESS_TYPE isolation2/regress] # [RUN_TIMES ] +# [EXCLUDE_FAULT_INJECT_TEST ] # ) # All the file path can be the relative path to ${CMAKE_CURRENT_SOURCE_DIR}. # A bunch of diff targets will be created as well for comparing the regress results. The diff @@ -51,11 +52,31 @@ function(_PGIsolation2Target_Add working_DIR) ) endfunction() +# Find all tests in the given directory which uses fault injector, and add them to +# fault_injector_test_list. +function(_Find_FaultInjector_Tests sql_DIR) + file(GLOB files "${sql_DIR}/*.sql") + foreach(f ${files}) + set(ret 1) + execute_process( + COMMAND + grep gp_inject_fault ${f} + OUTPUT_QUIET + RESULT_VARIABLE ret) + if(ret EQUAL 0) + get_filename_component(test_name ${f} NAME_WLE) + list(APPEND fault_injector_test_list ${test_name}) + endif() + endforeach() + + set(fault_injector_test_list ${fault_injector_test_list} PARENT_SCOPE) +endfunction() + function(RegressTarget_Add name) cmake_parse_arguments( arg "" - "SQL_DIR;EXPECTED_DIR;RESULTS_DIR;DATA_DIR;REGRESS_TYPE;RUN_TIMES" + "SQL_DIR;EXPECTED_DIR;RESULTS_DIR;DATA_DIR;REGRESS_TYPE;RUN_TIMES;EXCLUDE_FAULT_INJECT_TEST" "REGRESS;EXCLUDE;REGRESS_OPTS;INIT_FILE;SCHEDULE_FILE" ${ARGN}) if (NOT arg_EXPECTED_DIR) @@ -85,8 +106,16 @@ function(RegressTarget_Add name) endif() endif() + # Find all tests using fault injector + if(arg_EXCLUDE_FAULT_INJECT_TEST) + _Find_FaultInjector_Tests(${arg_SQL_DIR}) + endif() + # Set REGRESS test cases foreach(r IN LISTS arg_REGRESS) + if (arg_EXCLUDE_FAULT_INJECT_TEST AND (r IN_LIST fault_injector_test_list)) + continue() + endif() set(regress_arg ${regress_arg} ${r}) endforeach() @@ -102,12 +131,20 @@ function(RegressTarget_Add name) foreach(o IN LISTS arg_EXCLUDE) list(APPEND to_exclude ${o}) endforeach() + if(arg_EXCLUDE_FAULT_INJECT_TEST) + list(APPEND to_exclude ${fault_injector_test_list}) + endif() if (to_exclude) set(exclude_arg "--exclude-tests=${to_exclude}") string(REPLACE ";" "," exclude_arg "${exclude_arg}") set(regress_opts_arg ${regress_opts_arg} ${exclude_arg}) endif() foreach(o IN LISTS arg_REGRESS_OPTS) + # If the fault injection tests are excluded, ignore the --load-extension=gp_inject_fault as + # well. + if (arg_EXCLUDE_FAULT_INJECT_TEST AND (o MATCHES ".*inject_fault")) + continue() + endif() set(regress_opts_arg ${regress_opts_arg} ${o}) endforeach() diff --git a/concourse/pipeline/job_def.lib.yml b/concourse/pipeline/job_def.lib.yml index 7e39bbaa..78119ad5 100644 --- a/concourse/pipeline/job_def.lib.yml +++ b/concourse/pipeline/job_def.lib.yml @@ -231,9 +231,7 @@ plan: - get: last_released_diskquota_bin resource: #@ conf["res_diskquota_bin"] - #@ _build_task(conf) -#@ if conf["build_type"] != "Release": - #@ _test_task(conf) -#@ end - put: #@ conf["res_intermediates_bin"] params: file: diskquota_artifacts/diskquota.tar.gz diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9a774572..13cc145a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,12 @@ if (${GP_MAJOR_VERSION} EQUAL 7) set(EXPECTED_DIR_SUFFIX "7") endif() +set(exclude_fault_injector OFF) +# GP7 release build doesn't support fault injector. +if (CMAKE_BUILD_TYPE STREQUAL "Release") + message(WARNING "Fault injector test cases will be disabled.") + set(exclude_fault_injector ON) +endif() RegressTarget_Add(regress INIT_FILE @@ -13,6 +19,7 @@ RegressTarget_Add(regress RESULTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/results DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/regress/diskquota_schedule${EXPECTED_DIR_SUFFIX} + EXCLUDE_FAULT_INJECT_TEST ${exclude_fault_injector} REGRESS_OPTS --load-extension=gp_inject_fault --load-extension=diskquota_test @@ -28,6 +35,7 @@ RegressTarget_Add(isolation2 RESULTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/results DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/isolation2_schedule${EXPECTED_DIR_SUFFIX} + EXCLUDE_FAULT_INJECT_TEST ${exclude_fault_injector} REGRESS_OPTS --load-extension=gp_inject_fault --dbname=isolation2test) From 3283772c17b2b73ca93bd64c03a21faa53729cf3 Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Wed, 15 Feb 2023 16:55:27 +0800 Subject: [PATCH 08/31] VAR replace for Regress.cmake and fix test_rejectmap (#304) Since GP7 doesn't support plpythonu, the test_rejectmap was broken for GP7. This commit: - Improve the Regress.cmake, so if the input sql file has a "in.sql" extension, "@VAR@" in it will be replaced by the corresponding cmake VAR. - SQL_DIR/EXPECTED_DIR takes list as the argument now. So only the different cases need to be put into the expected7. Others will be used from expected directly. - Due to above change, same tests for gp6 and gp7 are removed from gp7, only diff is needed. - Set different @PLPYTHON_LANG_STR@ for GP6 & GP7 - Due to plpython composite type behavior change, the python code in the test has been modified. The behavior change is probably related to PG commit 94aceed317. --- cmake/Regress.cmake | 68 +- tests/CMakeLists.txt | 12 +- tests/init_file | 2 + tests/isolation2/expected/test_rejectmap.out | 4 +- tests/isolation2/expected7/config.out | 30 - tests/isolation2/expected7/reset_config.out | 10 - .../expected7/test_create_extension.out | 15 - .../expected7/test_drop_extension.out | 12 - .../expected7/test_fast_quota_view.out | 182 ----- .../expected7/test_postmaster_restart.out | 139 ---- tests/isolation2/expected7/test_rejectmap.out | 738 ------------------ .../expected7/test_relation_cache.out | 70 -- .../expected7/test_relation_size.out | 87 --- tests/isolation2/expected7/test_truncate.out | 86 -- tests/isolation2/expected7/test_vacuum.out | 99 --- .../expected7/test_worker_timeout.out | 38 - tests/isolation2/isolation2_schedule7 | 2 +- ...st_rejectmap.sql => test_rejectmap.in.sql} | 31 +- tests/regress/expected7/config.out | 70 -- tests/regress/expected7/reset_config.out | 17 - .../expected7/test_activetable_limit.out | 56 -- .../test_clean_rejectmap_after_drop.out | 42 - tests/regress/expected7/test_column.out | 42 - tests/regress/expected7/test_copy.out | 26 - .../expected7/test_create_extension.out | 14 - .../expected7/test_ctas_before_set_quota.out | 61 -- .../expected7/test_ctas_no_preload_lib.out | 85 -- tests/regress/expected7/test_ctas_pause.out | 37 - tests/regress/expected7/test_ctas_role.out | 81 -- tests/regress/expected7/test_ctas_schema.out | 64 -- .../expected7/test_ctas_tablespace_role.out | 78 -- .../expected7/test_ctas_tablespace_schema.out | 74 -- .../expected7/test_default_tablespace.out | 186 ----- tests/regress/expected7/test_delete_quota.out | 37 - .../expected7/test_drop_after_pause.out | 64 -- .../regress/expected7/test_drop_extension.out | 13 - tests/regress/expected7/test_drop_table.out | 34 - tests/regress/expected7/test_extension.out | 523 ------------- .../expected7/test_fast_disk_check.out | 23 - .../expected7/test_fetch_table_stat.out | 35 - tests/regress/expected7/test_index.out | 133 ---- .../expected7/test_many_active_tables.out | 31 - tests/regress/expected7/test_mistake.out | 34 - tests/regress/expected7/test_partition.out | 63 -- .../expected7/test_pause_and_resume.out | 70 -- .../test_pause_and_resume_multiple_db.out | 201 ----- .../expected7/test_primary_failure.out | 126 --- .../expected7/test_quota_view_no_table.out | 64 -- .../expected7/test_readiness_logged.out | 38 - tests/regress/expected7/test_recreate.out | 27 - .../expected7/test_rejectmap_mul_db.out | 79 -- .../regress/expected7/test_relation_size.out | 99 --- tests/regress/expected7/test_rename.out | 71 -- tests/regress/expected7/test_reschema.out | 39 - tests/regress/expected7/test_role.out | 138 ---- tests/regress/expected7/test_schema.out | 109 --- tests/regress/expected7/test_show_status.out | 67 -- .../expected7/test_tablespace_diff_schema.out | 87 --- .../expected7/test_tablespace_role.out | 194 ----- .../expected7/test_tablespace_role_perseg.out | 235 ------ .../expected7/test_tablespace_schema.out | 147 ---- .../test_tablespace_schema_perseg.out | 282 ------- tests/regress/expected7/test_temp_role.out | 40 - tests/regress/expected7/test_toast.out | 31 - tests/regress/expected7/test_truncate.out | 36 - tests/regress/expected7/test_update.out | 23 - .../expected7/test_update_db_cache.out | 64 -- tests/regress/expected7/test_vacuum.out | 57 -- .../expected7/test_worker_not_ready.out | 26 - .../expected7/test_worker_schedule.out | 633 --------------- .../test_worker_schedule_exception.out | 113 --- 71 files changed, 86 insertions(+), 6558 deletions(-) delete mode 100644 tests/isolation2/expected7/config.out delete mode 100644 tests/isolation2/expected7/reset_config.out delete mode 100644 tests/isolation2/expected7/test_create_extension.out delete mode 100644 tests/isolation2/expected7/test_drop_extension.out delete mode 100644 tests/isolation2/expected7/test_fast_quota_view.out delete mode 100644 tests/isolation2/expected7/test_postmaster_restart.out delete mode 100644 tests/isolation2/expected7/test_rejectmap.out delete mode 100644 tests/isolation2/expected7/test_relation_cache.out delete mode 100644 tests/isolation2/expected7/test_relation_size.out delete mode 100644 tests/isolation2/expected7/test_truncate.out delete mode 100644 tests/isolation2/expected7/test_vacuum.out delete mode 100644 tests/isolation2/expected7/test_worker_timeout.out rename tests/isolation2/sql/{test_rejectmap.sql => test_rejectmap.in.sql} (97%) delete mode 100644 tests/regress/expected7/config.out delete mode 100644 tests/regress/expected7/reset_config.out delete mode 100644 tests/regress/expected7/test_activetable_limit.out delete mode 100644 tests/regress/expected7/test_clean_rejectmap_after_drop.out delete mode 100644 tests/regress/expected7/test_column.out delete mode 100644 tests/regress/expected7/test_copy.out delete mode 100644 tests/regress/expected7/test_create_extension.out delete mode 100644 tests/regress/expected7/test_ctas_before_set_quota.out delete mode 100644 tests/regress/expected7/test_ctas_no_preload_lib.out delete mode 100644 tests/regress/expected7/test_ctas_pause.out delete mode 100644 tests/regress/expected7/test_ctas_role.out delete mode 100644 tests/regress/expected7/test_ctas_schema.out delete mode 100644 tests/regress/expected7/test_ctas_tablespace_role.out delete mode 100644 tests/regress/expected7/test_ctas_tablespace_schema.out delete mode 100644 tests/regress/expected7/test_default_tablespace.out delete mode 100644 tests/regress/expected7/test_delete_quota.out delete mode 100644 tests/regress/expected7/test_drop_after_pause.out delete mode 100644 tests/regress/expected7/test_drop_extension.out delete mode 100644 tests/regress/expected7/test_drop_table.out delete mode 100644 tests/regress/expected7/test_extension.out delete mode 100644 tests/regress/expected7/test_fast_disk_check.out delete mode 100644 tests/regress/expected7/test_fetch_table_stat.out delete mode 100644 tests/regress/expected7/test_index.out delete mode 100644 tests/regress/expected7/test_many_active_tables.out delete mode 100644 tests/regress/expected7/test_mistake.out delete mode 100644 tests/regress/expected7/test_partition.out delete mode 100644 tests/regress/expected7/test_pause_and_resume.out delete mode 100644 tests/regress/expected7/test_pause_and_resume_multiple_db.out delete mode 100644 tests/regress/expected7/test_primary_failure.out delete mode 100644 tests/regress/expected7/test_quota_view_no_table.out delete mode 100644 tests/regress/expected7/test_readiness_logged.out delete mode 100644 tests/regress/expected7/test_recreate.out delete mode 100644 tests/regress/expected7/test_rejectmap_mul_db.out delete mode 100644 tests/regress/expected7/test_relation_size.out delete mode 100644 tests/regress/expected7/test_rename.out delete mode 100644 tests/regress/expected7/test_reschema.out delete mode 100644 tests/regress/expected7/test_role.out delete mode 100644 tests/regress/expected7/test_schema.out delete mode 100644 tests/regress/expected7/test_show_status.out delete mode 100644 tests/regress/expected7/test_tablespace_diff_schema.out delete mode 100644 tests/regress/expected7/test_tablespace_role.out delete mode 100644 tests/regress/expected7/test_tablespace_role_perseg.out delete mode 100644 tests/regress/expected7/test_tablespace_schema.out delete mode 100644 tests/regress/expected7/test_tablespace_schema_perseg.out delete mode 100644 tests/regress/expected7/test_temp_role.out delete mode 100644 tests/regress/expected7/test_toast.out delete mode 100644 tests/regress/expected7/test_truncate.out delete mode 100644 tests/regress/expected7/test_update.out delete mode 100644 tests/regress/expected7/test_update_db_cache.out delete mode 100644 tests/regress/expected7/test_vacuum.out delete mode 100644 tests/regress/expected7/test_worker_not_ready.out delete mode 100644 tests/regress/expected7/test_worker_schedule.out delete mode 100644 tests/regress/expected7/test_worker_schedule_exception.out diff --git a/cmake/Regress.cmake b/cmake/Regress.cmake index 62d8807f..11f23f47 100644 --- a/cmake/Regress.cmake +++ b/cmake/Regress.cmake @@ -2,8 +2,8 @@ # # Usage: # RegressTarget_Add( -# SQL_DIR -# EXPECTED_DIR +# SQL_DIR [ ...] +# EXPECTED_DIR [ ...] # RESULTS_DIR # [INIT_FILE ...] # [SCHEDULE_FILE ...] @@ -25,6 +25,13 @@ # - regress_show_diff.sh # - regress_loop.sh # +# NOTE: If the input sql file extension is ".in.sql" instead of ".sql", the "@VAR@" in the input +# file will be replaced by the corresponding cmake VAR before tests are executed. +# +# NOTE: The directory that comes later in the SQL_DIR/EXPECTED_DIR list has a higher priory. The +# test case with the same name will be overwritten by the case that comes after in the directory +# list.t +# # Example: # RegressTarget_Add(installcheck_avro_fmt # REGRESS ${avro_regress_TARGETS} @@ -55,6 +62,12 @@ endfunction() # Find all tests in the given directory which uses fault injector, and add them to # fault_injector_test_list. function(_Find_FaultInjector_Tests sql_DIR) + if (NOT fault_injector_test_list) + set(fault_injector_test_list "" PARENT_SCOPE) + endif() + set(test_list ${fault_injector_test_list}) + + get_filename_component(sql_DIR ${sql_DIR} ABSOLUTE) file(GLOB files "${sql_DIR}/*.sql") foreach(f ${files}) set(ret 1) @@ -64,20 +77,38 @@ function(_Find_FaultInjector_Tests sql_DIR) OUTPUT_QUIET RESULT_VARIABLE ret) if(ret EQUAL 0) - get_filename_component(test_name ${f} NAME_WLE) - list(APPEND fault_injector_test_list ${test_name}) + get_filename_component(test_name ${f} NAME_WE) + if (NOT test_name IN_LIST test_list) + list(APPEND test_list ${test_name}) + endif() endif() endforeach() - set(fault_injector_test_list ${fault_injector_test_list} PARENT_SCOPE) + set(fault_injector_test_list ${test_list} PARENT_SCOPE) +endfunction() + +# Create symbolic links in the binary dir to input SQL files. +function(_Link_Test_Files src_DIR dest_DIR suffix) + get_filename_component(src_DIR ${src_DIR} ABSOLUTE) + file(MAKE_DIRECTORY ${dest_DIR}) + file(GLOB files "${src_DIR}/*.${suffix}") + foreach(f ${files}) + get_filename_component(file_name ${f} NAME) + file(CREATE_LINK ${f} ${dest_DIR}/${file_name} SYMBOLIC) + endforeach() + file(GLOB files "${src_DIR}/*.in.${suffix}") + foreach(f ${files}) + get_filename_component(file_name ${f} NAME_WE) + configure_file(${f} ${dest_DIR}/${file_name}.${suffix}) + endforeach() endfunction() function(RegressTarget_Add name) cmake_parse_arguments( arg "" - "SQL_DIR;EXPECTED_DIR;RESULTS_DIR;DATA_DIR;REGRESS_TYPE;RUN_TIMES;EXCLUDE_FAULT_INJECT_TEST" - "REGRESS;EXCLUDE;REGRESS_OPTS;INIT_FILE;SCHEDULE_FILE" + "RESULTS_DIR;DATA_DIR;REGRESS_TYPE;RUN_TIMES;EXCLUDE_FAULT_INJECT_TEST" + "SQL_DIR;EXPECTED_DIR;REGRESS;EXCLUDE;REGRESS_OPTS;INIT_FILE;SCHEDULE_FILE" ${ARGN}) if (NOT arg_EXPECTED_DIR) message(FATAL_ERROR @@ -106,10 +137,19 @@ function(RegressTarget_Add name) endif() endif() - # Find all tests using fault injector - if(arg_EXCLUDE_FAULT_INJECT_TEST) - _Find_FaultInjector_Tests(${arg_SQL_DIR}) - endif() + # Link input sql files to the build dir + foreach(sql_DIR IN LISTS arg_SQL_DIR) + _Link_Test_Files(${sql_DIR} ${working_DIR}/sql sql) + # Find all tests using fault injector + if(arg_EXCLUDE_FAULT_INJECT_TEST) + _Find_FaultInjector_Tests(${sql_DIR}) + endif() + endforeach() + + # Link output out files to the build dir + foreach(expected_DIR IN LISTS arg_EXPECTED_DIR) + _Link_Test_Files(${expected_DIR} ${working_DIR}/expected out) + endforeach() # Set REGRESS test cases foreach(r IN LISTS arg_REGRESS) @@ -148,8 +188,6 @@ function(RegressTarget_Add name) set(regress_opts_arg ${regress_opts_arg} ${o}) endforeach() - get_filename_component(sql_DIR ${arg_SQL_DIR} ABSOLUTE) - get_filename_component(expected_DIR ${arg_EXPECTED_DIR} ABSOLUTE) get_filename_component(results_DIR ${arg_RESULTS_DIR} ABSOLUTE) if (arg_DATA_DIR) get_filename_component(data_DIR ${arg_DATA_DIR} ABSOLUTE) @@ -171,10 +209,6 @@ function(RegressTarget_Add name) add_custom_target( ${name} WORKING_DIRECTORY ${working_DIR} - COMMAND rm -f sql - COMMAND ln -s ${sql_DIR} sql - COMMAND rm -f expected - COMMAND ln -s ${expected_DIR} expected COMMAND rm -f results COMMAND mkdir -p ${results_DIR} COMMAND ln -s ${results_DIR} results diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 13cc145a..07abaf69 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,15 @@ include(${CMAKE_SOURCE_DIR}/cmake/Regress.cmake) +list(APPEND isolation2_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/expected) +list(APPEND regress_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/expected) if (${GP_MAJOR_VERSION} EQUAL 7) set(EXPECTED_DIR_SUFFIX "7") + list(APPEND isolation2_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/expected7) + list(APPEND regress_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/expected7) + # PLPYTHON_LANG_STR will be replaced by Regress.cmake + set(PLPYTHON_LANG_STR "plpython3u") +else() + set(PLPYTHON_LANG_STR "plpython2u") endif() set(exclude_fault_injector OFF) @@ -15,7 +23,7 @@ RegressTarget_Add(regress INIT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/init_file SQL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/sql - EXPECTED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/expected${EXPECTED_DIR_SUFFIX} + EXPECTED_DIR ${regress_expected_DIR} RESULTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/results DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/regress/diskquota_schedule${EXPECTED_DIR_SUFFIX} @@ -31,7 +39,7 @@ RegressTarget_Add(isolation2 INIT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/init_file SQL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/sql - EXPECTED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/expected${EXPECTED_DIR_SUFFIX} + EXPECTED_DIR ${isolation2_expected_DIR} RESULTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/results DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/isolation2_schedule${EXPECTED_DIR_SUFFIX} diff --git a/tests/init_file b/tests/init_file index 477b1355..ff2ea6bf 100644 --- a/tests/init_file +++ b/tests/init_file @@ -18,6 +18,8 @@ m/diskquota_utility.c:\d+\)/ s/diskquota_utility.c:\d+\)/diskquota_utility.c:xxx/ m/^CONTEXT:*/ s/^CONTEXT:/DETAIL:/ +m/plpython\du/ +s/plpython\du/plpythonu/ # Remove segment identifiers from error message. # E.g., (slice1 XXX.XXX.XXX.XXX:XXXX pid=XXXX) diff --git a/tests/isolation2/expected/test_rejectmap.out b/tests/isolation2/expected/test_rejectmap.out index 5e15acce..2ed02900 100644 --- a/tests/isolation2/expected/test_rejectmap.out +++ b/tests/isolation2/expected/test_rejectmap.out @@ -301,7 +301,7 @@ CREATE TYPE cached_relation_entry AS ( reloid oid, relname text, re CREATE -- This function dumps given relation_cache entries to the given file. -CREATE OR REPLACE FUNCTION dump_relation_cache_to_file(filename text) RETURNS void AS $$ rv = plpy.execute(""" SELECT (oid, relname, relowner, relnamespace, reltablespace, relfilenode, gp_segment_id)::cached_relation_entry FROM gp_dist_random('pg_class') """) with open(filename, 'wt') as f: for v in rv: f.write(v['row'][1:-1] + '\n') $$ LANGUAGE plpythonu; +CREATE OR REPLACE FUNCTION dump_relation_cache_to_file(filename text) RETURNS void AS $$ rv = plpy.execute(""" SELECT (oid, relname, relowner, relnamespace, reltablespace, relfilenode, gp_segment_id)::cached_relation_entry FROM gp_dist_random('pg_class') """) with open(filename, 'wt') as f: for v in rv: row = v['row'] # The composite type results are different between GP6 & GP7 if isinstance(row, dict): r = "{0},{1},{2},{3},{4},{5},{6}".format( row['reloid'], row['relname'], row['relowner'], row['relnamespace'], row['reltablespace'], row['relfilenode'], row['segid']) else: r = row[1:-1] f.write(r + '\n') $$ LANGUAGE plpython2u; CREATE -- This function reads relation_cache entries from the given file. @@ -310,7 +310,7 @@ CREATE -- This function replaces the oid appears in the auxiliary relation's name -- with the corresponding relname of that oid. -CREATE OR REPLACE FUNCTION replace_oid_with_relname(given_name text, filename text) RETURNS text AS $$ /*in func*/ BEGIN /*in func*/ RETURN COALESCE( /*in func*/ REGEXP_REPLACE(given_name, /*in func*/ '^(pg_toast_|pg_aoseg_|pg_aovisimap_|pg_aoblkdir_|pg_aocsseg_)\d+', /*in func*/ '\1' || /*in func*/ (SELECT DISTINCT relname FROM read_relation_cache_from_file(filename) /*in func*/ WHERE REGEXP_REPLACE(given_name, '\D', '', 'g') <> '' AND reloid=REGEXP_REPLACE(given_name, '\D', '', 'g')::oid), 'g'), given_name);/*in func*/ END; /*in func*/ $$ LANGUAGE plpgsql; +CREATE OR REPLACE FUNCTION replace_oid_with_relname(given_name text, filename text) RETURNS text AS $$ /*in func*/ BEGIN /*in func*/ RETURN COALESCE( /*in func*/ REGEXP_REPLACE(given_name, /*in func*/ '^(pg_toast_|pg_aoseg_|pg_aovisimap_|pg_aoblkdir_|pg_aocsseg_)\d+', /*in func*/ '\1' || /*in func*/ (SELECT DISTINCT relname FROM read_relation_cache_from_file(filename) /*in func*/ WHERE REGEXP_REPLACE(given_name, '\D', '', 'g') <> '' /*in func*/ AND reloid=REGEXP_REPLACE(given_name, '\D', '', 'g')::oid), 'g'), given_name); /*in func*/ END; /*in func*/ $$ LANGUAGE plpgsql; CREATE -- This function helps dispatch rejectmap for the given relation to seg0. diff --git a/tests/isolation2/expected7/config.out b/tests/isolation2/expected7/config.out deleted file mode 100644 index 8ad8cbd0..00000000 --- a/tests/isolation2/expected7/config.out +++ /dev/null @@ -1,30 +0,0 @@ - -!\retcode gpconfig -c shared_preload_libraries -v $(./data/current_binary_name); -(exited with code 0) -!\retcode gpconfig -c diskquota.naptime -v 0 --skipvalidation; -(exited with code 0) -!\retcode gpconfig -c max_worker_processes -v 20 --skipvalidation; -(exited with code 0) - -!\retcode gpstop -raf; -(exited with code 0) - --- Show the values of all GUC variables ---start_ignore --- naptime cannot be 0 for release build -1: SHOW diskquota.naptime; - diskquota.naptime -------------------- - 0 -(1 row) ---end_ignore -1: SHOW diskquota.max_active_tables; - diskquota.max_active_tables ------------------------------ - 307200 -(1 row) -1: SHOW diskquota.worker_timeout; - diskquota.worker_timeout --------------------------- - 60 -(1 row) diff --git a/tests/isolation2/expected7/reset_config.out b/tests/isolation2/expected7/reset_config.out deleted file mode 100644 index 3d076b36..00000000 --- a/tests/isolation2/expected7/reset_config.out +++ /dev/null @@ -1,10 +0,0 @@ -!\retcode gpconfig -c diskquota.naptime -v 2; -(exited with code 0) -!\retcode gpstop -u; -(exited with code 0) - -1: SHOW diskquota.naptime; - diskquota.naptime -------------------- - 2 -(1 row) diff --git a/tests/isolation2/expected7/test_create_extension.out b/tests/isolation2/expected7/test_create_extension.out deleted file mode 100644 index 211ebd63..00000000 --- a/tests/isolation2/expected7/test_create_extension.out +++ /dev/null @@ -1,15 +0,0 @@ -CREATE EXTENSION diskquota; -CREATE - -SELECT diskquota.init_table_size_table(); - init_table_size_table ------------------------ - -(1 row) - --- Wait after init so that diskquota.state is clean -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) diff --git a/tests/isolation2/expected7/test_drop_extension.out b/tests/isolation2/expected7/test_drop_extension.out deleted file mode 100644 index 4a9e4ecb..00000000 --- a/tests/isolation2/expected7/test_drop_extension.out +++ /dev/null @@ -1,12 +0,0 @@ -SELECT diskquota.pause(); - pause -------- - -(1 row) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -DROP EXTENSION diskquota; -DROP diff --git a/tests/isolation2/expected7/test_fast_quota_view.out b/tests/isolation2/expected7/test_fast_quota_view.out deleted file mode 100644 index 22bde748..00000000 --- a/tests/isolation2/expected7/test_fast_quota_view.out +++ /dev/null @@ -1,182 +0,0 @@ -CREATE SCHEMA s1; -CREATE -CREATE SCHEMA s2; -CREATE - -CREATE ROLE r LOGIN SUPERUSER; -CREATE - -!\retcode mkdir -p /tmp/spc1; --- start_ignore - --- end_ignore -(exited with code 0) -!\retcode mkdir -p /tmp/spc2; --- start_ignore - --- end_ignore -(exited with code 0) - -DROP TABLESPACE IF EXISTS spc1; -DROP -CREATE TABLESPACE spc1 LOCATION '/tmp/spc1'; -CREATE -DROP TABLESPACE IF EXISTS spc2; -DROP -CREATE TABLESPACE spc2 LOCATION '/tmp/spc2'; -CREATE - -SELECT diskquota.set_schema_quota('s1', '100 MB'); - set_schema_quota ------------------- - -(1 row) -SELECT diskquota.set_schema_tablespace_quota('s2', 'spc1','100 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) -SELECT diskquota.set_role_quota('r', '100 MB'); - set_role_quota ----------------- - -(1 row) -SELECT diskquota.set_role_tablespace_quota('r', 'spc2', '100 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - --- test show_fast_schema_quota_view and show_fast_schema_tablespace_quota_view -1: BEGIN; -BEGIN -1: CREATE TABLE s1.t(i int) DISTRIBUTED BY (i); -CREATE -1: INSERT INTO s1.t SELECT generate_series(1, 100000); -INSERT 100000 - -1: CREATE TABLE s2.t(i int) TABLESPACE spc1 DISTRIBUTED BY (i); -CREATE -1: INSERT INTO s2.t SELECT generate_series(1, 100000); -INSERT 100000 - -1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- check schema quota view before transaction commits -2: SELECT schema_name, quota_in_mb, nspsize_in_bytes FROM diskquota.show_fast_schema_quota_view; - schema_name | quota_in_mb | nspsize_in_bytes --------------+-------------+------------------ - s1 | 100 | 3932160 -(1 row) -2: SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes --------------+-----------------+-------------+----------------------------- - s2 | spc1 | 100 | 3932160 -(1 row) - -1: COMMIT; -COMMIT -2: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -2: SELECT schema_name, quota_in_mb, nspsize_in_bytes FROM diskquota.show_fast_schema_quota_view; - schema_name | quota_in_mb | nspsize_in_bytes --------------+-------------+------------------ - s1 | 100 | 3932160 -(1 row) -2: SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes --------------+-----------------+-------------+----------------------------- - s2 | spc1 | 100 | 3932160 -(1 row) - --- login r to test role quota view -1: SET ROLE r; -SET - --- test show_fast_role_quota_view and show_fast_role_tablespace_quota_view -1: BEGIN; -BEGIN -1: CREATE TABLE t1(i int) DISTRIBUTED BY (i); -CREATE -1: INSERT INTO t1 SELECT generate_series(1, 100000); -INSERT 100000 - -1: CREATE TABLE t2(i int) TABLESPACE spc2 DISTRIBUTED BY (i); -CREATE -1: INSERT INTO t2 SELECT generate_series(1, 100000); -INSERT 100000 - -1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- check role quota view before transaction commits -2: SELECT role_name, quota_in_mb, rolsize_in_bytes FROM diskquota.show_fast_role_quota_view; - role_name | quota_in_mb | rolsize_in_bytes ------------+-------------+------------------ - r | 100 | 7864320 -(1 row) -2: SELECT role_name, tablespace_name, quota_in_mb, rolsize_tablespace_in_bytes FROM diskquota.show_fast_role_tablespace_quota_view; - role_name | tablespace_name | quota_in_mb | rolsize_tablespace_in_bytes ------------+-----------------+-------------+----------------------------- - r | spc2 | 100 | 3932160 -(1 row) - -1: COMMIT; -COMMIT -2: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -2: SELECT role_name, quota_in_mb, rolsize_in_bytes FROM diskquota.show_fast_role_quota_view; - role_name | quota_in_mb | rolsize_in_bytes ------------+-------------+------------------ - r | 100 | 7864320 -(1 row) -2: SELECT role_name, tablespace_name, quota_in_mb, rolsize_tablespace_in_bytes FROM diskquota.show_fast_role_tablespace_quota_view; - role_name | tablespace_name | quota_in_mb | rolsize_tablespace_in_bytes ------------+-----------------+-------------+----------------------------- - r | spc2 | 100 | 3932160 -(1 row) - -DROP TABLE IF EXISTS s1.t; -DROP -DROP TABLE IF EXISTS s2.t; -DROP -DROP TABLE IF EXISTS t1; -DROP -DROP TABLE IF EXISTS t2; -DROP - -DROP SCHEMA IF EXISTS s1; -DROP -DROP SCHEMA IF EXISTS s2; -DROP -DROP ROLE IF EXISTS r; -DROP - -DROP TABLESPACE IF EXISTS spc1; -DROP -DROP TABLESPACE IF EXISTS spc2; -DROP - -!\retcode rm -rf /tmp/spc1; --- start_ignore - --- end_ignore -(exited with code 0) -!\retcode rm -rf /tmp/spc2; --- start_ignore - --- end_ignore -(exited with code 0) diff --git a/tests/isolation2/expected7/test_postmaster_restart.out b/tests/isolation2/expected7/test_postmaster_restart.out deleted file mode 100644 index 5f01eee9..00000000 --- a/tests/isolation2/expected7/test_postmaster_restart.out +++ /dev/null @@ -1,139 +0,0 @@ -!\retcode gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null; --- start_ignore - --- end_ignore -(exited with code 0) -!\retcode gpstop -u > /dev/null; --- start_ignore - --- end_ignore -(exited with code 0) - -1: CREATE SCHEMA postmaster_restart_s; -CREATE -1: SET search_path TO postmaster_restart_s; -SET - -1: SELECT diskquota.set_schema_quota('postmaster_restart_s', '1 MB'); - set_schema_quota ------------------- - -(1 row) -1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect fail -1: CREATE TABLE t1 AS SELECT generate_series(1,10000000); -ERROR: schema's disk space quota exceeded with name: 157893 (seg0 127.0.0.1:6002 pid=1025673) -1q: ... - --- launcher should exist --- [p]ostgres is to filter out the pgrep itself -!\retcode pgrep -f "[p]ostgres.*launcher"; --- start_ignore -2774491 - --- end_ignore -(exited with code 0) --- bgworker should exist -!\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; --- start_ignore -2774659 - --- end_ignore -(exited with code 0) - --- stop postmaster -!\retcode pg_ctl -D $MASTER_DATA_DIRECTORY -w stop; --- start_ignore -waiting for server to shut down.... done -server stopped --- end_ignore -(exited with code 0) - --- launcher should be terminated -!\retcode pgrep -f "[p]ostgres.*launcher"; --- start_ignore - --- end_ignore -(exited with code 1) --- bgworker should be terminated -!\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; --- start_ignore - --- end_ignore -(exited with code 1) - --- start postmaster --- -E needs to be changed to "-c gp_role=dispatch" for GPDB7 --- See https://github.com/greenplum-db/gpdb/pull/9396 -!\retcode pg_ctl -D $MASTER_DATA_DIRECTORY -w -o "-E" start; --- start_ignore -waiting for server to start....2022-02-14 21:41:39.147869 CST,,,p1017570,th1516906368,,,,0,,,seg-1,,,,,"LOG","00000","registering background worker ""ftsprobe process""",,,,,,,,"RegisterBackgroundWorker","bgworker.c",773, -2022-02-14 21:41:39.147899 CST,,,p1017570,th1516906368,,,,0,,,seg-1,,,,,"LOG","00000","registering background worker ""dtx recovery process""",,,,,,,,"RegisterBackgroundWorker","bgworker.c",773, -2022-02-14 21:41:39.147934 CST,,,p1017570,th1516906368,,,,0,,,seg-1,,,,,"LOG","00000","registering background worker ""sweeper process""",,,,,,,,"RegisterBackgroundWorker","bgworker.c",773, -2022-02-14 21:41:39.148550 CST,,,p1017570,th1516906368,,,,0,,,seg-1,,,,,"LOG","00000","registering background worker ""[diskquota] - launcher""",,,,,,,,"RegisterBackgroundWorker","bgworker.c",773, -2022-02-14 21:41:39.272714 CST,,,p1017570,th1516906368,,,,0,,,seg-1,,,,,"LOG","00000","redirecting log output to logging collector process",,"Future log output will appear in directory ""pg_log"".",,,,,,"SysLogger_Start","syslogger.c",986, - done -server started - --- end_ignore -(exited with code 0) --- Hopefully the bgworker can be started in 5 seconds -!\retcode sleep 5; --- start_ignore - --- end_ignore -(exited with code 0) - --- launcher should be restarted -!\retcode pgrep -f "[p]ostgres.*launcher"; --- start_ignore -2771049 - --- end_ignore -(exited with code 0) --- bgworker should be restarted -!\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; --- start_ignore -2771074 - --- end_ignore -(exited with code 0) - -1: SET search_path TO postmaster_restart_s; -SET -1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) --- expect fail -1: CREATE TABLE t2 AS SELECT generate_series(1,10000000); -ERROR: schema's disk space quota exceeded with name: 158089 (seg0 127.0.0.1:6002 pid=1027799) --- enlarge the quota limits -1: SELECT diskquota.set_schema_quota('postmaster_restart_s', '100 MB'); - set_schema_quota ------------------- - -(1 row) -1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) --- expect succeed -1: CREATE TABLE t3 AS SELECT generate_series(1,1000000); -CREATE 1000000 - -1: DROP SCHEMA postmaster_restart_s CASCADE; -DROP -1q: ... -!\retcode gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null; --- start_ignore - --- end_ignore -(exited with code 0) diff --git a/tests/isolation2/expected7/test_rejectmap.out b/tests/isolation2/expected7/test_rejectmap.out deleted file mode 100644 index 5e15acce..00000000 --- a/tests/isolation2/expected7/test_rejectmap.out +++ /dev/null @@ -1,738 +0,0 @@ --- --- This file contains tests for dispatching rejectmap and canceling --- queries in smgrextend hook by relation's relfilenode. --- - --- Enable check quota by relfilenode on seg0. -SELECT gp_inject_fault_infinite('enable_check_quota_by_relfilenode', 'skip', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- this function return valid tablespaceoid. --- For role/namespace quota, return as it is. --- For namespace_tablespace/role_tablespace quota, return non-zero tablespaceoid. -CREATE OR REPLACE FUNCTION get_real_tablespace_oid(block_type text, tablespaceoid oid) /*in func*/ RETURNS oid AS /*in func*/ $$ /*in func*/ BEGIN /*in func*/ /*in func*/ CASE /*in func*/ WHEN (block_type = 'NAMESPACE') OR (block_type = 'ROLE') THEN RETURN tablespaceoid; /*in func*/ ELSE RETURN ( /*in func*/ CASE tablespaceoid /*in func*/ WHEN 0 THEN (SELECT dattablespace FROM pg_database WHERE datname = CURRENT_DATABASE()) /*in func*/ ELSE /*in func*/ tablespaceoid /*in func*/ END /*in func*/ ); /*in func*/ END CASE; /*in func*/ END; /*in func*/ $$ LANGUAGE plpgsql; /*in func*/ -CREATE OR REPLACE FUNCTION block_relation_on_seg0(rel regclass, block_type text, segexceeded boolean) RETURNS void AS $$ /*in func*/ DECLARE /*in func*/ bt int; /*in func*/ targetoid oid; /*in func*/ BEGIN /*in func*/ CASE block_type /*in func*/ WHEN 'NAMESPACE' THEN /*in func*/ bt = 0; /*in func*/ SELECT relnamespace INTO targetoid /*in func*/ FROM pg_class WHERE relname=rel::text; /*in func*/ WHEN 'ROLE' THEN /*in func*/ bt = 1; /*in func*/ SELECT relowner INTO targetoid /*in func*/ FROM pg_class WHERE relname=rel::text; /*in func*/ WHEN 'NAMESPACE_TABLESPACE' THEN /*in func*/ bt = 2; /*in func*/ SELECT relnamespace INTO targetoid /*in func*/ FROM pg_class WHERE relname=rel::text; /*in func*/ WHEN 'ROLE_TABLESPACE' THEN /*in func*/ bt = 3; /*in func*/ SELECT relowner INTO targetoid /*in func*/ FROM pg_class WHERE relname=rel::text; /*in func*/ END CASE; /*in func*/ PERFORM diskquota.refresh_rejectmap( /*in func*/ ARRAY[ /*in func*/ ROW (targetoid, /*in func*/ (SELECT oid FROM pg_database WHERE datname = CURRENT_DATABASE()), /*in func*/ (SELECT get_real_tablespace_oid( /*in func*/ block_type, /*in func*/ (SELECT pg_class.reltablespace FROM pg_class WHERE relname = rel::TEXT) /*in func*/ )), /*in func*/ bt, /*in func*/ segexceeded) /*in func*/ ]::diskquota.rejectmap_entry[], /*in func*/ ARRAY[rel]::oid[]) /*in func*/ FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; /*in func*/ END; $$ /*in func*/ LANGUAGE 'plpgsql'; -CREATE - --- 1. Test canceling the extending of an ordinary table. -CREATE TABLE blocked_t1(i int) DISTRIBUTED BY (i); -CREATE -INSERT INTO blocked_t1 SELECT generate_series(1, 100); -INSERT 100 --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Insert a small amount of data into blocked_t1. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t1 SELECT generate_series(1, 10000); - -SELECT gp_wait_until_triggered_fault('check_rejectmap_by_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_wait_until_triggered_fault -------------------------------- - Success: -(1 row) - --- Dispatch rejectmap to seg0. -SELECT block_relation_on_seg0('blocked_t1'::regclass, 'NAMESPACE'::text, false); - block_relation_on_seg0 ------------------------- - -(1 row) - -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Session 1 will return and emit an error message saying that the quota limit is exceeded on seg0. -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) - --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 2. Test canceling the extending of a toast relation. -CREATE TABLE blocked_t2(i text) DISTRIBUTED BY (i); -CREATE -INSERT INTO blocked_t2 SELECT generate_series(1, 100); -INSERT 100 --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Insert a small amount of data into blocked_t2. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t2 SELECT generate_series(1, 10000); - -SELECT gp_wait_until_triggered_fault('check_rejectmap_by_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_wait_until_triggered_fault -------------------------------- - Success: -(1 row) - --- Dispatch rejectmap to seg0. -SELECT block_relation_on_seg0('blocked_t2'::regclass, 'NAMESPACE'::text, false); - block_relation_on_seg0 ------------------------- - -(1 row) - -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Session 1 will return and emit an error message saying that the quota limit is exceeded on seg0. -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) - --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 3. Test canceling the extending of an appendonly relation. -CREATE TABLE blocked_t3(i int) WITH (appendonly=true) DISTRIBUTED BY (i); -CREATE -INSERT INTO blocked_t3 SELECT generate_series(1, 100); -INSERT 100 --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Insert a small amount of data into blocked_t3. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t3 SELECT generate_series(1, 10000); - -SELECT gp_wait_until_triggered_fault('check_rejectmap_by_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_wait_until_triggered_fault -------------------------------- - Success: -(1 row) - --- Dispatch rejectmap to seg0. -SELECT block_relation_on_seg0('blocked_t3'::regclass, 'NAMESPACE'::text, false); - block_relation_on_seg0 ------------------------- - -(1 row) - -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Session 1 will return and emit an error message saying that the quota limit is exceeded on seg0. -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) - --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 4. Test canceling the extending of an index relation. -CREATE TABLE blocked_t4(i int) DISTRIBUTED BY (i); -CREATE -CREATE INDEX blocked_t4_index ON blocked_t4(i); -CREATE -INSERT INTO blocked_t4 SELECT generate_series(1, 100); -INSERT 100 --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Insert a small amount of data into blocked_t4. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t4 SELECT generate_series(1, 10000); - -SELECT gp_wait_until_triggered_fault('check_rejectmap_by_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_wait_until_triggered_fault -------------------------------- - Success: -(1 row) - --- Dispatch rejectmap to seg0. -SELECT block_relation_on_seg0('blocked_t4_index'::regclass, 'NAMESPACE'::text, false); - block_relation_on_seg0 ------------------------- - -(1 row) - -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Session 1 will return and emit an error message saying that the quota limit is exceeded on seg0. -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) - --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 5. Test error message for NAMESPACE_TABLESPACE_QUOTA when the quota limit is exceeded on segments. -CREATE TABLE blocked_t5(i int) DISTRIBUTED BY (i); -CREATE -INSERT INTO blocked_t5 SELECT generate_series(1, 100); -INSERT 100 --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1&: INSERT INTO blocked_t5 SELECT generate_series(1, 10000); - -SELECT gp_wait_until_triggered_fault('check_rejectmap_by_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_wait_until_triggered_fault -------------------------------- - Success: -(1 row) - -SELECT block_relation_on_seg0('blocked_t5'::regclass, 'NAMESPACE_TABLESPACE'::text, true); - block_relation_on_seg0 ------------------------- - -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: tablespace: 1663, schema: 2200 diskquota exceeded per segment quota (seg0 127.0.0.1:6002 pid=2163) --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 6. Test error message for ROLE_TABLESPACE_QUOTA when the quota limit is exceeded on segments. -CREATE TABLE blocked_t6(i int) DISTRIBUTED BY (i); -CREATE -INSERT INTO blocked_t6 SELECT generate_series(1, 100); -INSERT 100 --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - -1&: INSERT INTO blocked_t6 SELECT generate_series(1, 10000); - -SELECT gp_wait_until_triggered_fault('check_rejectmap_by_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_wait_until_triggered_fault -------------------------------- - Success: -(1 row) - -SELECT block_relation_on_seg0('blocked_t6'::regclass, 'ROLE_TABLESPACE'::text, true); - block_relation_on_seg0 ------------------------- - -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: tablespace: 1663, role: 10 diskquota exceeded per segment quota (seg0 127.0.0.1:6002 pid=2163) --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- Do some clean-ups. -DROP TABLE blocked_t1; -DROP -DROP TABLE blocked_t2; -DROP -DROP TABLE blocked_t3; -DROP -DROP TABLE blocked_t4; -DROP -DROP TABLE blocked_t5; -DROP -DROP TABLE blocked_t6; -DROP - --- --- Below are helper functions for testing adding uncommitted relations to rejectmap. --- --- start_ignore -CREATE OR REPLACE LANGUAGE plpythonu; -CREATE --- end_ignore -CREATE TYPE cached_relation_entry AS ( reloid oid, relname text, relowner oid, relnamespace oid, reltablespace oid, relfilenode oid, segid int); -CREATE - --- This function dumps given relation_cache entries to the given file. -CREATE OR REPLACE FUNCTION dump_relation_cache_to_file(filename text) RETURNS void AS $$ rv = plpy.execute(""" SELECT (oid, relname, relowner, relnamespace, reltablespace, relfilenode, gp_segment_id)::cached_relation_entry FROM gp_dist_random('pg_class') """) with open(filename, 'wt') as f: for v in rv: f.write(v['row'][1:-1] + '\n') $$ LANGUAGE plpythonu; -CREATE - --- This function reads relation_cache entries from the given file. -CREATE OR REPLACE FUNCTION read_relation_cache_from_file(filename text) RETURNS SETOF cached_relation_entry AS $$ with open(filename) as f: for l in f: r = l.split(',') yield (r[0], r[1], r[2], r[3], r[4], r[5], r[6]) $$ LANGUAGE plpythonu; -CREATE - --- This function replaces the oid appears in the auxiliary relation's name --- with the corresponding relname of that oid. -CREATE OR REPLACE FUNCTION replace_oid_with_relname(given_name text, filename text) RETURNS text AS $$ /*in func*/ BEGIN /*in func*/ RETURN COALESCE( /*in func*/ REGEXP_REPLACE(given_name, /*in func*/ '^(pg_toast_|pg_aoseg_|pg_aovisimap_|pg_aoblkdir_|pg_aocsseg_)\d+', /*in func*/ '\1' || /*in func*/ (SELECT DISTINCT relname FROM read_relation_cache_from_file(filename) /*in func*/ WHERE REGEXP_REPLACE(given_name, '\D', '', 'g') <> '' AND reloid=REGEXP_REPLACE(given_name, '\D', '', 'g')::oid), 'g'), given_name);/*in func*/ END; /*in func*/ $$ LANGUAGE plpgsql; -CREATE - --- This function helps dispatch rejectmap for the given relation to seg0. -CREATE OR REPLACE FUNCTION block_uncommitted_relation_on_seg0(rel text, block_type text, segexceeded boolean, filename text) RETURNS void AS $$ /*in func*/ DECLARE /*in func*/ bt int; /*in func*/ targetoid oid; /*in func*/ BEGIN /*in func*/ CASE block_type /*in func*/ WHEN 'NAMESPACE' THEN /*in func*/ bt = 0; /*in func*/ SELECT relnamespace INTO targetoid /*in func*/ FROM read_relation_cache_from_file(filename) /*in func*/ WHERE relname=rel::text AND segid=0; /*in func*/ WHEN 'ROLE' THEN /*in func*/ bt = 1; /*in func*/ SELECT relowner INTO targetoid /*in func*/ FROM read_relation_cache_from_file(filename) /*in func*/ WHERE relname=rel::text AND segid=0; /*in func*/ WHEN 'NAMESPACE_TABLESPACE' THEN /*in func*/ bt = 2; /*in func*/ SELECT relnamespace INTO targetoid /*in func*/ FROM read_relation_cache_from_file(filename) /*in func*/ WHERE relname=rel::text AND segid=0; /*in func*/ WHEN 'ROLE_TABLESPACE' THEN /*in func*/ bt = 3; /*in func*/ SELECT relowner INTO targetoid /*in func*/ FROM read_relation_cache_from_file(filename) /*in func*/ WHERE relname=rel::text AND segid=0; /*in func*/ END CASE; /*in func*/ PERFORM diskquota.refresh_rejectmap( /*in func*/ ARRAY[ /*in func*/ ROW (targetoid, /*in func*/ (SELECT oid FROM pg_database WHERE datname = CURRENT_DATABASE()), /*in func*/ (SELECT get_real_tablespace_oid( /*in func*/ block_type, /*in func*/ (SELECT reltablespace /*in func*/ FROM read_relation_cache_from_file(filename) /*in func*/ WHERE relname = rel::text /*in func*/ AND segid = 0) /*in func*/ )), /*in func*/ bt, /*in func*/ segexceeded) /*in func*/ ]::diskquota.rejectmap_entry[], /*in func*/ ARRAY[(SELECT reloid FROM read_relation_cache_from_file(filename) /*in func*/ WHERE relname=rel::text AND segid=0)::regclass]::oid[]) /*in func*/ FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; /*in func*/ END; $$ /*in func*/ LANGUAGE 'plpgsql'; -CREATE - --- 7. Test that we are able to block an ordinary relation on seg0 by its relnamespace. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'NAMESPACE'::text, false, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text), be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0; - segid | relnamespace | reltablespace | relowner | replace_oid_with_relname | target_type | target_oid --------+--------------+---------------+----------+--------------------------+-----------------+------------ - 0 | 2200 | 0 | 10 | blocked_t7 | NAMESPACE_QUOTA | 2200 -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 8. Test that we are able to block an ordinary relation on seg0 by its relowner. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'ROLE'::text, false, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text), be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0; - segid | relnamespace | reltablespace | relowner | replace_oid_with_relname | target_type | target_oid --------+--------------+---------------+----------+--------------------------+-------------+------------ - 0 | 2200 | 0 | 10 | blocked_t7 | ROLE_QUOTA | 10 -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: role's disk space quota exceeded with name: 10 (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 9. Test that we are able to block an ordinary relation on seg0 by its relnamespace and reltablespace. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'NAMESPACE_TABLESPACE'::text, false, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text), be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0; - segid | relnamespace | reltablespace | relowner | replace_oid_with_relname | target_type | target_oid --------+--------------+---------------+----------+--------------------------+----------------------------+------------ - 0 | 2200 | 0 | 10 | blocked_t7 | NAMESPACE_TABLESPACE_QUOTA | 2200 -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: tablespace: 1663, schema: 2200 diskquota exceeded (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 10. Test that we are able to block an ordinary relation on seg0 by its relowner and reltablespace. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'ROLE_TABLESPACE'::text, false, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text), be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0; - segid | relnamespace | reltablespace | relowner | replace_oid_with_relname | target_type | target_oid --------+--------------+---------------+----------+--------------------------+-----------------------+------------ - 0 | 2200 | 0 | 10 | blocked_t7 | ROLE_TABLESPACE_QUOTA | 10 -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: tablespace: 1663, role: 10 diskquota exceeded (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 11. Test that we are able to block an ordinary relation on seg0 by its relnamespace and reltablespace (segexceeded=true). -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'NAMESPACE_TABLESPACE'::text, true, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text), be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0; - segid | relnamespace | reltablespace | relowner | replace_oid_with_relname | target_type | target_oid --------+--------------+---------------+----------+--------------------------+----------------------------+------------ - 0 | 2200 | 0 | 10 | blocked_t7 | NAMESPACE_TABLESPACE_QUOTA | 2200 -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: tablespace: 1663, schema: 2200 diskquota exceeded per segment quota (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 12. Test that we are able to block an ordinary relation on seg0 by its relowner and reltablespace (segexceeded=true). -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'ROLE_TABLESPACE'::text, true, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text), be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0; - segid | relnamespace | reltablespace | relowner | replace_oid_with_relname | target_type | target_oid --------+--------------+---------------+----------+--------------------------+-----------------------+------------ - 0 | 2200 | 0 | 10 | blocked_t7 | ROLE_TABLESPACE_QUOTA | 10 -(1 row) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: tablespace: 1663, role: 10 diskquota exceeded per segment quota (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 13. Test that we are able to block a toast relation on seg0 by its namespace. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i text) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'NAMESPACE'::text, true, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text) AS relname, be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0 ORDER BY relname DESC; - segid | relnamespace | reltablespace | relowner | relname | target_type | target_oid --------+--------------+---------------+----------+---------------------------+-----------------+------------ - 0 | 99 | 0 | 10 | pg_toast_blocked_t7_index | NAMESPACE_QUOTA | 2200 - 0 | 99 | 0 | 10 | pg_toast_blocked_t7 | NAMESPACE_QUOTA | 2200 - 0 | 2200 | 0 | 10 | blocked_t7 | NAMESPACE_QUOTA | 2200 -(3 rows) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 14. Test that we are able to block an appendonly relation on seg0 by its namespace. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) WITH (appendonly=true) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'NAMESPACE'::text, true, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text) AS relname, be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0 ORDER BY relname DESC; - segid | relnamespace | reltablespace | relowner | relname | target_type | target_oid --------+--------------+---------------+----------+-------------------------------+-----------------+------------ - 0 | 6104 | 0 | 10 | pg_aovisimap_blocked_t7_index | NAMESPACE_QUOTA | 2200 - 0 | 6104 | 0 | 10 | pg_aovisimap_blocked_t7 | NAMESPACE_QUOTA | 2200 - 0 | 6104 | 0 | 10 | pg_aoseg_blocked_t7 | NAMESPACE_QUOTA | 2200 - 0 | 2200 | 0 | 10 | blocked_t7 | NAMESPACE_QUOTA | 2200 -(4 rows) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- 15. Test that we are able to block an appendonly (column oriented) relation on seg0 by its namespace. -1: BEGIN; -BEGIN -1: CREATE TABLE blocked_t7(i int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (i); -CREATE -1: SELECT dump_relation_cache_to_file('/tmp/test_rejectmap.csv'); - dump_relation_cache_to_file ------------------------------ - -(1 row) --- Inject 'suspension' to check_rejectmap_by_relfilenode on seg0. -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) --- Insert a small amount of data into blocked_t7. It will hang up at check_rejectmap_by_relfilenode(). -1&: INSERT INTO blocked_t7 SELECT generate_series(1, 10000); -SELECT block_uncommitted_relation_on_seg0('blocked_t7'::text, 'NAMESPACE'::text, true, '/tmp/test_rejectmap.csv'::text); - block_uncommitted_relation_on_seg0 ------------------------------------- - -(1 row) --- Show that blocked_t7 is blocked on seg0. -2: SELECT rel.segid, rel.relnamespace, rel.reltablespace, rel.relowner, replace_oid_with_relname(rel.relname, '/tmp/test_rejectmap.csv'::text) AS relname, be.target_type, be.target_oid FROM gp_dist_random('diskquota.rejectmap') AS be, read_relation_cache_from_file('/tmp/test_rejectmap.csv') AS rel WHERE be.segid=rel.segid AND be.relnode=rel.relfilenode AND rel.relfilenode<>0 ORDER BY relname DESC; - segid | relnamespace | reltablespace | relowner | relname | target_type | target_oid --------+--------------+---------------+----------+-------------------------------+-----------------+------------ - 0 | 6104 | 0 | 10 | pg_aovisimap_blocked_t7_index | NAMESPACE_QUOTA | 2200 - 0 | 6104 | 0 | 10 | pg_aovisimap_blocked_t7 | NAMESPACE_QUOTA | 2200 - 0 | 6104 | 0 | 10 | pg_aocsseg_blocked_t7 | NAMESPACE_QUOTA | 2200 - 0 | 2200 | 0 | 10 | blocked_t7 | NAMESPACE_QUOTA | 2200 -(4 rows) -SELECT gp_inject_fault_infinite('check_rejectmap_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) -1<: <... completed> -ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=2163) -1: ABORT; -ABORT --- Clean up the rejectmap on seg0. -SELECT diskquota.refresh_rejectmap( ARRAY[]::diskquota.rejectmap_entry[], ARRAY[]::oid[]) FROM gp_dist_random('gp_id') WHERE gp_segment_id=0; - refresh_rejectmap -------------------- - -(1 row) - --- Reset fault injection points set by us at the top of this test. -SELECT gp_inject_fault_infinite('enable_check_quota_by_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) diff --git a/tests/isolation2/expected7/test_relation_cache.out b/tests/isolation2/expected7/test_relation_cache.out deleted file mode 100644 index df61fdb8..00000000 --- a/tests/isolation2/expected7/test_relation_cache.out +++ /dev/null @@ -1,70 +0,0 @@ -CREATE DATABASE tempdb1; -CREATE -CREATE DATABASE tempdb2; -CREATE - --- perpare extension -1:@db_name tempdb1: CREATE EXTENSION diskquota; -CREATE -1:@db_name tempdb1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -2:@db_name tempdb2: CREATE EXTENSION diskquota; -CREATE -2:@db_name tempdb2: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- create a table in tempdb1 -1:@db_name tempdb1: BEGIN; -BEGIN -1:@db_name tempdb1: CREATE TABLE t(i int); -CREATE -1:@db_name tempdb1: INSERT INTO t select generate_series(1, 10000); -INSERT 10000 - --- query relation_cache in tempdb2 -2:@db_name tempdb2: SELECT count(*) from diskquota.show_relation_cache(); - count -------- - 0 -(1 row) - -1:@db_name tempdb1: ABORT; -ABORT - -1:@db_name tempdb1: SELECT diskquota.pause(); - pause -------- - -(1 row) -1:@db_name tempdb1: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -1:@db_name tempdb1: DROP EXTENSION diskquota; -DROP -2:@db_name tempdb2: SELECT diskquota.pause(); - pause -------- - -(1 row) -2:@db_name tempdb2: SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -2:@db_name tempdb2: DROP EXTENSION diskquota; -DROP -1q: ... -2q: ... - -DROP DATABASE tempdb1; -DROP -DROP DATABASE tempdb2; -DROP diff --git a/tests/isolation2/expected7/test_relation_size.out b/tests/isolation2/expected7/test_relation_size.out deleted file mode 100644 index 45e9a9cc..00000000 --- a/tests/isolation2/expected7/test_relation_size.out +++ /dev/null @@ -1,87 +0,0 @@ --- --- 1. Test that when a relation is dropped before diskquota.relation_size() --- applying stat(2) on the physical file, diskquota.relation_size() consumes --- the error and returns 0. --- - -CREATE TABLE t_dropped(i int) DISTRIBUTED BY (i); -CREATE --- Insert a small amount of data to 't_dropped'. -INSERT INTO t_dropped SELECT generate_series(1, 100); -INSERT 100 --- Shows that the size of relfilenode is not zero. -SELECT diskquota.relation_size('t_dropped'); - relation_size ---------------- - 98304 -(1 row) - --- Inject 'suspension' to servers. -SELECT gp_inject_fault_infinite('diskquota_before_stat_relfilenode', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content>=0; - gp_inject_fault_infinite --------------------------- - Success: - Success: - Success: -(3 rows) - --- Session 1 will hang before applying stat(2) to the physical file. -1&: SELECT diskquota.relation_size('t_dropped'); --- Wait until the fault is triggered to avoid the following race condition: --- The 't_dropped' table is dropped before evaluating "SELECT diskquota.relation_size('t_dropped')" --- and the query will fail with 'ERROR: relation "t_dropped" does not exist' -SELECT gp_wait_until_triggered_fault('diskquota_before_stat_relfilenode', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content>=0; - gp_wait_until_triggered_fault -------------------------------- - Success: - Success: - Success: -(3 rows) --- Drop the table. -DROP TABLE t_dropped; -DROP --- Remove the injected 'suspension'. -SELECT gp_inject_fault_infinite('diskquota_before_stat_relfilenode', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content>=0; - gp_inject_fault_infinite --------------------------- - Success: - Success: - Success: -(3 rows) --- Session 1 will continue and returns 0. -1<: <... completed> - relation_size ---------------- - 0 -(1 row) - --- 2. Test whether relation size is correct under concurrent writes for AO tables. --- Since no row is deleted, diskquota.relation_size() should be equal to --- pg_relation_size(). - -CREATE TABLE t_ao(i int) WITH (appendonly=true) DISTRIBUTED BY (i); -CREATE -1: BEGIN; -BEGIN -1: INSERT INTO t_ao SELECT generate_series(1, 10000); -INSERT 10000 -2: BEGIN; -BEGIN -2: INSERT INTO t_ao SELECT generate_series(1, 10000); -INSERT 10000 -1: COMMIT; -COMMIT -2: COMMIT; -COMMIT -SELECT diskquota.relation_size('t_ao'); - relation_size ---------------- - 200400 -(1 row) -SELECT pg_relation_size('t_ao'); - pg_relation_size ------------------- - 200400 -(1 row) -DROP TABLE t_ao; -DROP diff --git a/tests/isolation2/expected7/test_truncate.out b/tests/isolation2/expected7/test_truncate.out deleted file mode 100644 index 4964f6ec..00000000 --- a/tests/isolation2/expected7/test_truncate.out +++ /dev/null @@ -1,86 +0,0 @@ --- Test various race conditions for TRUNCATE. - --- Case 1: Pulling active table before swapping relfilenode -CREATE TABLE dummy_t1(i int) DISTRIBUTED BY (i); -CREATE -INSERT INTO dummy_t1 SELECT generate_series(1, 1000); -INSERT 1000 --- Wait for the diskquota bgworker refreshing the size of 'dummy_t1'. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) --- Shows that the result of pg_table_size() and diskquota.table_size are identical. -SELECT pg_table_size('dummy_t1'); - pg_table_size ---------------- - 98304 -(1 row) -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid='dummy_t1'::regclass ORDER BY segid; - tableid | size | segid -----------+-------+------- - dummy_t1 | 98304 | -1 - dummy_t1 | 32768 | 0 - dummy_t1 | 32768 | 1 - dummy_t1 | 32768 | 2 -(4 rows) - -SELECT gp_inject_fault_infinite('diskquota_after_smgrcreate', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; - gp_inject_fault_infinite --------------------------- - Success: - Success: - Success: -(3 rows) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -1&: TRUNCATE dummy_t1; -SELECT gp_wait_until_triggered_fault('diskquota_after_smgrcreate', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; - gp_wait_until_triggered_fault -------------------------------- - Success: - Success: - Success: -(3 rows) --- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -SELECT gp_inject_fault_infinite('diskquota_after_smgrcreate', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; - gp_inject_fault_infinite --------------------------- - Success: - Success: - Success: -(3 rows) -1<: <... completed> -TRUNCATE - --- Wait for the diskquota bgworker refreshing the size of 'dummy_t1'. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) --- Shows that the result of pg_table_size() and diskquota.table_size are identical. -SELECT pg_table_size('dummy_t1'); - pg_table_size ---------------- - 0 -(1 row) -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid='dummy_t1'::regclass ORDER BY segid; - tableid | size | segid -----------+------+------- - dummy_t1 | 0 | -1 - dummy_t1 | 0 | 0 - dummy_t1 | 0 | 1 - dummy_t1 | 0 | 2 -(4 rows) -DROP TABLE dummy_t1; -DROP diff --git a/tests/isolation2/expected7/test_vacuum.out b/tests/isolation2/expected7/test_vacuum.out deleted file mode 100644 index eb437932..00000000 --- a/tests/isolation2/expected7/test_vacuum.out +++ /dev/null @@ -1,99 +0,0 @@ --- This file tests various race conditions when performing 'VACUUM FULL'. - --- 1. When the gpdb is performing 'VACUUM FULL' on some relation, it can be summarized --- as the following 3 steps: --- s1) create a new temporary relation (smgrcreate hook will be triggered, newly --- created relfilenode will be put into shmem). --- s2) insert data into the newly created relation from the old relation (smgrextend --- hook will be triggered, newly created relfilenode will be put into shmem). --- s3) change the old relation's relfilenode to the newly created one. --- Consider the following situation: --- If the diskquota bgworker pulls active oids before the 'VACUUM FULL' operation finishing, --- the newly created relfilenode is translated to the newly created temporary relation's oid, --- the old relation's size cannot be updated. We resolve it by making altered relations' oids --- constantly active so that the diskquota bgworker keeps updating the altered relation size --- during 'VACUUM FULL'. -CREATE TABLE dummy_t1(i int) DISTRIBUTED BY (i); -CREATE -INSERT INTO dummy_t1 SELECT generate_series(1, 1000); -INSERT 1000 -DELETE FROM dummy_t1; -DELETE 1000 --- Wait for the diskquota bgworker refreshing the size of 'dummy_t1'. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) --- Shows that the result of pg_table_size() and diskquota.table_size are identical. -SELECT pg_table_size('dummy_t1'); - pg_table_size ---------------- - 98304 -(1 row) -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid='dummy_t1'::regclass ORDER BY segid; - tableid | size | segid -----------+-------+------- - dummy_t1 | 98304 | -1 - dummy_t1 | 32768 | 0 - dummy_t1 | 32768 | 1 - dummy_t1 | 32768 | 2 -(4 rows) -SELECT gp_inject_fault_infinite('object_access_post_alter', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; - gp_inject_fault_infinite --------------------------- - Success: - Success: - Success: -(3 rows) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -1&: VACUUM FULL dummy_t1; -SELECT gp_wait_until_triggered_fault('object_access_post_alter', 1, dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; - gp_wait_until_triggered_fault -------------------------------- - Success: - Success: - Success: -(3 rows) --- Wait for the diskquota bgworker 'consumes' the newly created relfilenode from shmem. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) -SELECT gp_inject_fault_infinite('object_access_post_alter', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content<>-1; - gp_inject_fault_infinite --------------------------- - Success: - Success: - Success: -(3 rows) -1<: <... completed> -VACUUM - --- Wait for the diskquota bgworker refreshing the size of 'dummy_t1'. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) --- Shows that the result of pg_table_size() and diskquota.table_size are identical. -SELECT pg_table_size('dummy_t1'); - pg_table_size ---------------- - 0 -(1 row) -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid='dummy_t1'::regclass ORDER BY segid; - tableid | size | segid -----------+------+------- - dummy_t1 | 0 | -1 - dummy_t1 | 0 | 0 - dummy_t1 | 0 | 1 - dummy_t1 | 0 | 2 -(4 rows) -DROP TABLE dummy_t1; -DROP diff --git a/tests/isolation2/expected7/test_worker_timeout.out b/tests/isolation2/expected7/test_worker_timeout.out deleted file mode 100644 index 5f855a7b..00000000 --- a/tests/isolation2/expected7/test_worker_timeout.out +++ /dev/null @@ -1,38 +0,0 @@ -!\retcode gpconfig -c diskquota.worker_timeout -v 1; -(exited with code 0) -!\retcode gpstop -u; -(exited with code 0) - -SELECT gp_inject_fault_infinite('diskquota_worker_main', 'suspend', dbid) FROM gp_segment_configuration WHERE role='p' AND content=-1; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - -1&: SELECT diskquota.wait_for_worker_new_epoch(); - -SELECT pg_sleep(2 * current_setting('diskquota.worker_timeout')::int); - pg_sleep ----------- - -(1 row) - -SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE query = 'SELECT diskquota.wait_for_worker_new_epoch();'; - pg_cancel_backend -------------------- - t -(1 row) - -SELECT gp_inject_fault_infinite('diskquota_worker_main', 'resume', dbid) FROM gp_segment_configuration WHERE role='p' AND content=-1; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - -1<: <... completed> -ERROR: canceling statement due to user request - -!\retcode gpconfig -r diskquota.worker_timeout; -(exited with code 0) -!\retcode gpstop -u; -(exited with code 0) diff --git a/tests/isolation2/isolation2_schedule7 b/tests/isolation2/isolation2_schedule7 index 56792ee6..04e9b5c7 100644 --- a/tests/isolation2/isolation2_schedule7 +++ b/tests/isolation2/isolation2_schedule7 @@ -2,7 +2,7 @@ test: config test: test_create_extension test: test_fast_quota_view test: test_relation_size -# test: test_rejectmap +test: test_rejectmap test: test_vacuum test: test_truncate # test: test_postmaster_restart diff --git a/tests/isolation2/sql/test_rejectmap.sql b/tests/isolation2/sql/test_rejectmap.in.sql similarity index 97% rename from tests/isolation2/sql/test_rejectmap.sql rename to tests/isolation2/sql/test_rejectmap.in.sql index 41267c56..3ad115f1 100644 --- a/tests/isolation2/sql/test_rejectmap.sql +++ b/tests/isolation2/sql/test_rejectmap.in.sql @@ -230,7 +230,7 @@ DROP TABLE blocked_t6; -- Below are helper functions for testing adding uncommitted relations to rejectmap. -- -- start_ignore -CREATE OR REPLACE LANGUAGE plpythonu; +CREATE OR REPLACE LANGUAGE @PLPYTHON_LANG_STR@; -- end_ignore CREATE TYPE cached_relation_entry AS ( reloid oid, @@ -253,18 +253,27 @@ AS $$ """) with open(filename, 'wt') as f: for v in rv: - f.write(v['row'][1:-1] + '\n') -$$ LANGUAGE plpythonu; + row = v['row'] + # The composite type results are different between GP6 & GP7 + if isinstance(row, dict): + r = "{0},{1},{2},{3},{4},{5},{6}".format( + row['reloid'], row['relname'], row['relowner'], + row['relnamespace'], row['reltablespace'], + row['relfilenode'], row['segid']) + else: + r = row[1:-1] + f.write(r + '\n') +$$ LANGUAGE @PLPYTHON_LANG_STR@; -- This function reads relation_cache entries from the given file. CREATE OR REPLACE FUNCTION read_relation_cache_from_file(filename text) RETURNS SETOF cached_relation_entry AS $$ - with open(filename) as f: - for l in f: - r = l.split(',') - yield (r[0], r[1], r[2], r[3], r[4], r[5], r[6]) -$$ LANGUAGE plpythonu; + with open(filename) as f: + for l in f: + r = l.split(',') + yield (r[0], r[1], r[2], r[3], r[4], r[5], r[6]) +$$ LANGUAGE @PLPYTHON_LANG_STR@; -- This function replaces the oid appears in the auxiliary relation's name -- with the corresponding relname of that oid. @@ -275,9 +284,9 @@ CREATE OR REPLACE FUNCTION replace_oid_with_relname(given_name text, filename te REGEXP_REPLACE(given_name, /*in func*/ '^(pg_toast_|pg_aoseg_|pg_aovisimap_|pg_aoblkdir_|pg_aocsseg_)\d+', /*in func*/ '\1' || /*in func*/ - (SELECT DISTINCT relname FROM read_relation_cache_from_file(filename) /*in func*/ - WHERE REGEXP_REPLACE(given_name, '\D', '', 'g') <> '' - AND reloid=REGEXP_REPLACE(given_name, '\D', '', 'g')::oid), 'g'), given_name);/*in func*/ + (SELECT DISTINCT relname FROM read_relation_cache_from_file(filename) /*in func*/ + WHERE REGEXP_REPLACE(given_name, '\D', '', 'g') <> '' /*in func*/ + AND reloid=REGEXP_REPLACE(given_name, '\D', '', 'g')::oid), 'g'), given_name); /*in func*/ END; /*in func*/ $$ LANGUAGE plpgsql; diff --git a/tests/regress/expected7/config.out b/tests/regress/expected7/config.out deleted file mode 100644 index d266f9bf..00000000 --- a/tests/regress/expected7/config.out +++ /dev/null @@ -1,70 +0,0 @@ ---start_ignore -CREATE DATABASE diskquota; -ERROR: database "diskquota" already exists -\! gpconfig -c shared_preload_libraries -v $(./data/current_binary_name); -20230117:12:40:53:1895897 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c shared_preload_libraries -v diskquota-2.2.so' -\! gpconfig -c diskquota.naptime -v 0 --skipvalidation -20230117:12:40:53:1896062 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.naptime -v 0 --skipvalidation' -\! gpconfig -c max_worker_processes -v 20 --skipvalidation -20230117:12:40:54:1896331 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c max_worker_processes -v 20 --skipvalidation' -\! gpconfig -c diskquota.hard_limit -v "off" --skipvalidation -20230117:12:40:55:1896588 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.hard_limit -v off --skipvalidation' -\! gpconfig -c diskquota.max_workers -v 1 --skipvalidation -20230117:12:40:55:1896848 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.max_workers -v 1 --skipvalidation' -\! gpconfig -c log_min_messages -v debug1 -20230117:12:40:56:1897088 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c log_min_messages -v debug1' -\! gpstop -raf -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -raf -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:12:40:56:1897362 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:12:40:57:1897362 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:12:40:58:1897362 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore -\c --- Show the values of all GUC variables --- start_ignore -SHOW diskquota.naptime; - diskquota.naptime -------------------- - 0 -(1 row) - --- end_ignore -SHOW diskquota.max_active_tables; - diskquota.max_active_tables ------------------------------ - 307200 -(1 row) - -SHOW diskquota.worker_timeout; - diskquota.worker_timeout --------------------------- - 60 -(1 row) - -SHOW diskquota.hard_limit; - diskquota.hard_limit ----------------------- - off -(1 row) - diff --git a/tests/regress/expected7/reset_config.out b/tests/regress/expected7/reset_config.out deleted file mode 100644 index 9f679725..00000000 --- a/tests/regress/expected7/reset_config.out +++ /dev/null @@ -1,17 +0,0 @@ ---start_ignore -\! gpconfig -c diskquota.naptime -v 2 -20230117:13:11:41:2012767 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.naptime -v 2' -\! gpstop -u -20230117:13:11:41:2012942 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -u -20230117:13:11:41:2012942 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:13:11:41:2012942 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:13:11:41:2012942 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:13:11:41:2012942 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:13:11:41:2012942 gpstop:zhrt:zhrt-[INFO]:-Signalling all postmaster processes to reload ---end_ignore -SHOW diskquota.naptime; - diskquota.naptime -------------------- - 2 -(1 row) - diff --git a/tests/regress/expected7/test_activetable_limit.out b/tests/regress/expected7/test_activetable_limit.out deleted file mode 100644 index c556f32b..00000000 --- a/tests/regress/expected7/test_activetable_limit.out +++ /dev/null @@ -1,56 +0,0 @@ --- table in 'diskquota not enabled database' should not be activetable -\! gpconfig -c diskquota.max_active_tables -v 2 > /dev/null -\! gpstop -arf > /dev/null -\c -CREATE DATABASE test_tablenum_limit_01; -CREATE DATABASE test_tablenum_limit_02; -\c test_tablenum_limit_01 -CREATE TABLE a01(i int) DISTRIBUTED BY (i); -CREATE TABLE a02(i int) DISTRIBUTED BY (i); -CREATE TABLE a03(i int) DISTRIBUTED BY (i); -INSERT INTO a01 values(generate_series(0, 500)); -INSERT INTO a02 values(generate_series(0, 500)); -INSERT INTO a03 values(generate_series(0, 500)); -\c test_tablenum_limit_02 -CREATE EXTENSION diskquota; -CREATE SCHEMA s; -SELECT diskquota.set_schema_quota('s', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE TABLE s.t1(i int) DISTRIBUTED BY (i); -- activetable = 1 -INSERT INTO s.t1 SELECT generate_series(1, 100000); -- ok. diskquota soft limit does not check when first write -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE TABLE s.t2(i int) DISTRIBUTED BY (i); -- activetable = 2 -INSERT INTO s.t2 SELECT generate_series(1, 10); -- expect failed -ERROR: schema's disk space quota exceeded with name: s -CREATE TABLE s.t3(i int) DISTRIBUTED BY (i); -- activetable = 3 should not crash. -INSERT INTO s.t3 SELECT generate_series(1, 10); -- expect failed -ERROR: schema's disk space quota exceeded with name: s --- Q: why diskquota still works when activetable = 3? --- A: the activetable limit by shmem size, calculate by hash_estimate_size() --- the result will bigger than sizeof(DiskQuotaActiveTableEntry) * max_active_tables --- the real capacity of this data structure based on the hash conflict probability. --- so we can not predict when the data structure will be fill in fully. --- --- this test case is useless, remove this if anyone dislike it. --- but the hash capacity is smaller than 6, so the test case works for issue 51 -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE test_tablenum_limit_01; -DROP DATABASE test_tablenum_limit_02; -\! gpconfig -r diskquota.max_active_tables > /dev/null -\! gpstop -arf > /dev/null diff --git a/tests/regress/expected7/test_clean_rejectmap_after_drop.out b/tests/regress/expected7/test_clean_rejectmap_after_drop.out deleted file mode 100644 index 30c63756..00000000 --- a/tests/regress/expected7/test_clean_rejectmap_after_drop.out +++ /dev/null @@ -1,42 +0,0 @@ -CREATE DATABASE test_clean_rejectmap_after_drop; -\c test_clean_rejectmap_after_drop -CREATE EXTENSION diskquota; -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -CREATE ROLE r; -NOTICE: resource queue required -- using default resource queue "pg_default" -SELECT diskquota.set_role_quota('r', '1MB'); - set_role_quota ----------------- - -(1 row) - -CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); -ALTER TABLE b OWNER TO r; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO b SELECT generate_series(1, 100000000); -- fail -ERROR: role's disk space quota exceeded with name: 40071 (seg1 127.0.0.1:7003 pid=1958088) -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -INSERT INTO b SELECT generate_series(1, 100); -- ok -\c contrib_regression -DROP DATABASE test_clean_rejectmap_after_drop; -DROP ROLE r; -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null diff --git a/tests/regress/expected7/test_column.out b/tests/regress/expected7/test_column.out deleted file mode 100644 index a5eb051c..00000000 --- a/tests/regress/expected7/test_column.out +++ /dev/null @@ -1,42 +0,0 @@ --- Test alter table add column -CREATE SCHEMA scolumn; -SELECT diskquota.set_schema_quota('scolumn', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO scolumn; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE TABLE a2(i INT) DISTRIBUTED BY (i); --- expect fail -INSERT INTO a2 SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect fail -INSERT INTO a2 SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: scolumn -ALTER TABLE a2 ADD COLUMN j VARCHAR(50); -UPDATE a2 SET j = 'add value for column j'; -ERROR: schema's disk space quota exceeded with name: scolumn -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert failed after add column -INSERT INTO a2 SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: scolumn -DROP TABLE a2; -RESET search_path; -DROP SCHEMA scolumn; diff --git a/tests/regress/expected7/test_copy.out b/tests/regress/expected7/test_copy.out deleted file mode 100644 index 2c3fff9f..00000000 --- a/tests/regress/expected7/test_copy.out +++ /dev/null @@ -1,26 +0,0 @@ --- Test copy -CREATE SCHEMA s3; -SELECT diskquota.set_schema_quota('s3', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO s3; -\! seq 100 > /tmp/csmall.txt -CREATE TABLE c (i int) DISTRIBUTED BY (i); -COPY c FROM '/tmp/csmall.txt'; --- expect failed -INSERT INTO c SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect copy fail -COPY c FROM '/tmp/csmall.txt'; -ERROR: schema's disk space quota exceeded with name: s3 -DROP TABLE c; -RESET search_path; -DROP SCHEMA s3; diff --git a/tests/regress/expected7/test_create_extension.out b/tests/regress/expected7/test_create_extension.out deleted file mode 100644 index a90178ce..00000000 --- a/tests/regress/expected7/test_create_extension.out +++ /dev/null @@ -1,14 +0,0 @@ -CREATE EXTENSION diskquota; -SELECT diskquota.init_table_size_table(); - init_table_size_table ------------------------ - -(1 row) - --- Wait after init so that diskquota.state is clean -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - diff --git a/tests/regress/expected7/test_ctas_before_set_quota.out b/tests/regress/expected7/test_ctas_before_set_quota.out deleted file mode 100644 index ac69b2b5..00000000 --- a/tests/regress/expected7/test_ctas_before_set_quota.out +++ /dev/null @@ -1,61 +0,0 @@ -CREATE ROLE test SUPERUSER; -SET ROLE test; -CREATE TABLE t_before_set_quota (i) AS SELECT generate_series(1, 100000) -DISTRIBUTED BY (i); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size -WHERE tableid = 't_before_set_quota'::regclass ORDER BY segid; - tableid | size | segid ---------------------+---------+------- - t_before_set_quota | 3637248 | -1 - t_before_set_quota | 1212416 | 0 - t_before_set_quota | 1212416 | 1 - t_before_set_quota | 1212416 | 2 -(4 rows) - --- Ensure that the table is not active -SELECT diskquota.diskquota_fetch_table_stat(0, ARRAY[]::oid[]) -FROM gp_dist_random('gp_id'); - diskquota_fetch_table_stat ----------------------------- -(0 rows) - -SELECT diskquota.set_role_quota(current_role, '1MB'); - set_role_quota ----------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- Expect that current role is in the rejectmap -SELECT rolname FROM pg_authid, diskquota.rejectmap WHERE oid = target_oid; - rolname ---------- - test -(1 row) - -SELECT diskquota.set_role_quota(current_role, '-1'); - set_role_quota ----------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP TABLE t_before_set_quota; -RESET ROLE; -DROP ROLE test; diff --git a/tests/regress/expected7/test_ctas_no_preload_lib.out b/tests/regress/expected7/test_ctas_no_preload_lib.out deleted file mode 100644 index b85a18ac..00000000 --- a/tests/regress/expected7/test_ctas_no_preload_lib.out +++ /dev/null @@ -1,85 +0,0 @@ -\! gpconfig -c shared_preload_libraries -v '' > /dev/null -\! gpstop -far > /dev/null -\c -CREATE ROLE test SUPERUSER; -SET ROLE test; --- Create table with diskquota disabled -CREATE TABLE t_without_diskquota (i) AS SELECT generate_series(1, 100000) -DISTRIBUTED BY (i); -\! gpconfig -c shared_preload_libraries -v $(./data/current_binary_name) > /dev/null -\! gpstop -far > /dev/null -\c -SET ROLE test; --- Init table_size to include the table -SELECT diskquota.init_table_size_table(); - init_table_size_table ------------------------ - -(1 row) - --- Restart to load diskquota.table_size to the memory. -\! gpstop -far > /dev/null -\c -SET ROLE test; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size -WHERE tableid = 't_without_diskquota'::regclass ORDER BY segid; - tableid | size | segid ----------------------+---------+------- - t_without_diskquota | 3637248 | -1 - t_without_diskquota | 1212416 | 0 - t_without_diskquota | 1212416 | 1 - t_without_diskquota | 1212416 | 2 -(4 rows) - --- Ensure that the table is not active -SELECT diskquota.diskquota_fetch_table_stat(0, ARRAY[]::oid[]) -FROM gp_dist_random('gp_id'); - diskquota_fetch_table_stat ----------------------------- -(0 rows) - -SELECT diskquota.set_role_quota(current_role, '1MB'); - set_role_quota ----------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- Expect that current role is in the rejectmap -SELECT rolname FROM pg_authid, diskquota.rejectmap WHERE oid = target_oid; - rolname ---------- - test -(1 row) - -SELECT diskquota.set_role_quota(current_role, '-1'); - set_role_quota ----------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT rolname FROM pg_authid, diskquota.rejectmap WHERE oid = target_oid; - rolname ---------- -(0 rows) - -DROP TABLE t_without_diskquota; -RESET ROLE; -DROP ROLE test; diff --git a/tests/regress/expected7/test_ctas_pause.out b/tests/regress/expected7/test_ctas_pause.out deleted file mode 100644 index 76e02f10..00000000 --- a/tests/regress/expected7/test_ctas_pause.out +++ /dev/null @@ -1,37 +0,0 @@ -CREATE SCHEMA hardlimit_s; -SET search_path TO hardlimit_s; -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.set_schema_quota('hardlimit_s', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- heap table -CREATE TABLE t1 (i) AS SELECT generate_series(1,10000000) DISTRIBUTED BY (i); -- expect fail -ERROR: schema's disk space quota exceeded with name: 40272 (seg0 127.0.0.1:7002 pid=1962803) -SELECT diskquota.pause(); - pause -------- - -(1 row) - -CREATE TABLE t1 (i) AS SELECT generate_series(1,10000000) DISTRIBUTED BY (i); -- expect succeed --- disable hardlimit and do some clean-ups. -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.resume(); - resume --------- - -(1 row) - -DROP SCHEMA hardlimit_s CASCADE; -NOTICE: drop cascades to table t1 diff --git a/tests/regress/expected7/test_ctas_role.out b/tests/regress/expected7/test_ctas_role.out deleted file mode 100644 index facb95b5..00000000 --- a/tests/regress/expected7/test_ctas_role.out +++ /dev/null @@ -1,81 +0,0 @@ --- Test that diskquota is able to cancel a running CTAS query by the role quota. --- start_ignore -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null --- end_ignore -CREATE ROLE hardlimit_r; -NOTICE: resource queue required -- using default resource queue "pg_default" -SELECT diskquota.set_role_quota('hardlimit_r', '1MB'); - set_role_quota ----------------- - -(1 row) - -GRANT USAGE ON SCHEMA diskquota TO hardlimit_r; -SET ROLE hardlimit_r; --- heap table -CREATE TABLE t1 (i) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: role's disk space quota exceeded with name: 40279 (seg1 127.0.0.1:7003 pid=1964560) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- temp table -CREATE TEMP TABLE t2 (i) AS SELECT generate_series(1, 100000000); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'generate_series' 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. -ERROR: role's disk space quota exceeded with name: 40279 (seg1 127.0.0.1:7003 pid=1964560) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- toast table -CREATE TABLE toast_table (i) AS SELECT ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) DISTRIBUTED BY (i); -ERROR: role's disk space quota exceeded with name: 40279 (seg1 127.0.0.1:7003 pid=1964560) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- ao table -CREATE TABLE ao_table (i) WITH (appendonly=true) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: role's disk space quota exceeded with name: 40279 (seg0 127.0.0.1:7002 pid=1964561) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- aocs table -CREATE TABLE aocs_table WITH (appendonly=true, orientation=column) - AS SELECT i, ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) AS i; -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) 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. -ERROR: role's disk space quota exceeded with name: 40279 (seg0 127.0.0.1:7002 pid=1964561) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- disable hardlimit and do some clean-ups. -DROP TABLE IF EXISTS t1; -NOTICE: table "t1" does not exist, skipping -DROP TABLE IF EXISTS t2; -NOTICE: table "t2" does not exist, skipping -DROP TABLE IF EXISTS toast_table; -NOTICE: table "toast_table" does not exist, skipping -DROP TABLE IF EXISTS ao_table; -NOTICE: table "ao_table" does not exist, skipping -DROP TABLE IF EXISTS aocs_table; -NOTICE: table "aocs_table" does not exist, skipping -RESET ROLE; -REVOKE USAGE ON SCHEMA diskquota FROM hardlimit_r; -DROP ROLE hardlimit_r; -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null diff --git a/tests/regress/expected7/test_ctas_schema.out b/tests/regress/expected7/test_ctas_schema.out deleted file mode 100644 index e2e810d6..00000000 --- a/tests/regress/expected7/test_ctas_schema.out +++ /dev/null @@ -1,64 +0,0 @@ --- Test that diskquota is able to cancel a running CTAS query by the schema quota. -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -CREATE SCHEMA hardlimit_s; -SELECT diskquota.set_schema_quota('hardlimit_s', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO hardlimit_s; --- heap table -CREATE TABLE t1 (i) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: schema's disk space quota exceeded with name: 40394 (seg2 127.0.0.1:7004 pid=1966566) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- toast table -CREATE TABLE toast_table (i) - AS SELECT ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) DISTRIBUTED BY (i); -ERROR: schema's disk space quota exceeded with name: 40394 (seg1 127.0.0.1:7003 pid=1966565) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- ao table -CREATE TABLE ao_table (i) WITH (appendonly=true) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: schema's disk space quota exceeded with name: 40394 (seg0 127.0.0.1:7002 pid=1966564) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- aocs table -CREATE TABLE aocs_table WITH (appendonly=true, orientation=column) - AS SELECT i, ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) AS i; -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) 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. -ERROR: schema's disk space quota exceeded with name: 40394 (seg2 127.0.0.1:7004 pid=1966566) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- disable hardlimit and do some clean-ups. -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -DROP TABLE IF EXISTS t1; -NOTICE: table "t1" does not exist, skipping -DROP TABLE IF EXISTS toast_table; -NOTICE: table "toast_table" does not exist, skipping -DROP TABLE IF EXISTS ao_table; -NOTICE: table "ao_table" does not exist, skipping -DROP TABLE IF EXISTS aocs_table; -NOTICE: table "aocs_table" does not exist, skipping -RESET search_path; -DROP SCHEMA hardlimit_s; diff --git a/tests/regress/expected7/test_ctas_tablespace_role.out b/tests/regress/expected7/test_ctas_tablespace_role.out deleted file mode 100644 index c6d3bb63..00000000 --- a/tests/regress/expected7/test_ctas_tablespace_role.out +++ /dev/null @@ -1,78 +0,0 @@ --- Test that diskquota is able to cancel a running CTAS query by the tablespace role quota. -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null --- start_ignore -\! mkdir -p /tmp/ctas_rolespc --- end_ignore --- prepare role and tablespace. -DROP TABLESPACE IF EXISTS ctas_rolespc; -NOTICE: tablespace "ctas_rolespc" does not exist, skipping -CREATE TABLESPACE ctas_rolespc LOCATION '/tmp/ctas_rolespc'; -CREATE ROLE hardlimit_r; -NOTICE: resource queue required -- using default resource queue "pg_default" -GRANT USAGE ON SCHEMA diskquota TO hardlimit_r; -GRANT ALL ON TABLESPACE ctas_rolespc TO hardlimit_r; -SELECT diskquota.set_role_tablespace_quota('hardlimit_r', 'ctas_rolespc', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SET default_tablespace = ctas_rolespc; -SET ROLE hardlimit_r; --- heap table -CREATE TABLE t1 (i) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: tablespace: 40497, role: 40498 diskquota exceeded (seg1 127.0.0.1:7003 pid=1968424) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- toast table -CREATE TABLE toast_table (i) - AS SELECT ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) DISTRIBUTED BY (i); -ERROR: tablespace: 40497, role: 40498 diskquota exceeded (seg1 127.0.0.1:7003 pid=1968424) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- ao table -CREATE TABLE ao_table (i) WITH (appendonly=true) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: tablespace: 40497, role: 40498 diskquota exceeded (seg1 127.0.0.1:7003 pid=1968424) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- aocs table -CREATE TABLE aocs_table WITH (appendonly=true, orientation=column) - AS SELECT i, ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) AS i DISTRIBUTED BY (i); -ERROR: tablespace: 40497, role: 40498 diskquota exceeded (seg1 127.0.0.1:7003 pid=1968424) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- disable hardlimit and do some clean-ups. -DROP TABLE IF EXISTS t1; -NOTICE: table "t1" does not exist, skipping -DROP TABLE IF EXISTS t2; -NOTICE: table "t2" does not exist, skipping -DROP TABLE IF EXISTS toast_table; -NOTICE: table "toast_table" does not exist, skipping -DROP TABLE IF EXISTS ao_table; -NOTICE: table "ao_table" does not exist, skipping -DROP TABLE IF EXISTS aocs_table; -NOTICE: table "aocs_table" does not exist, skipping -RESET ROLE; -RESET default_tablespace; -DROP TABLESPACE ctas_rolespc; -REVOKE USAGE ON SCHEMA diskquota FROM hardlimit_r; -DROP ROLE hardlimit_r; -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null diff --git a/tests/regress/expected7/test_ctas_tablespace_schema.out b/tests/regress/expected7/test_ctas_tablespace_schema.out deleted file mode 100644 index 9c9bde2e..00000000 --- a/tests/regress/expected7/test_ctas_tablespace_schema.out +++ /dev/null @@ -1,74 +0,0 @@ --- Test that diskquota is able to cancel a running CTAS query by the tablespace schema quota. -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null --- start_ignore -\! mkdir -p /tmp/ctas_schemaspc --- end_ignore --- prepare tablespace and schema -DROP TABLESPACE IF EXISTS ctas_schemaspc; -NOTICE: tablespace "ctas_schemaspc" does not exist, skipping -CREATE TABLESPACE ctas_schemaspc LOCATION '/tmp/ctas_schemaspc'; -CREATE SCHEMA hardlimit_s; -SELECT diskquota.set_schema_tablespace_quota('hardlimit_s', 'ctas_schemaspc', '1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SET search_path TO hardlimit_s; -SET default_tablespace = ctas_schemaspc; --- heap table -CREATE TABLE t1 (i) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: tablespace: 40635, schema: 40636 diskquota exceeded (seg0 127.0.0.1:7002 pid=1970360) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- toast table -CREATE TABLE toast_table (i) - AS SELECT ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) DISTRIBUTED BY (i); -ERROR: tablespace: 40635, schema: 40636 diskquota exceeded (seg1 127.0.0.1:7003 pid=1970361) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- ao table -CREATE TABLE ao_table (i) WITH (appendonly=true) AS SELECT generate_series(1, 100000000) DISTRIBUTED BY (i); -ERROR: tablespace: 40635, schema: 40636 diskquota exceeded (seg0 127.0.0.1:7002 pid=1970360) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- aocs table -CREATE TABLE aocs_table WITH (appendonly=true, orientation=column) - AS SELECT i, ARRAY(SELECT generate_series(1,10000)) FROM generate_series(1, 100000) AS i DISTRIBUTED BY (i); -ERROR: tablespace: 40635, schema: 40636 diskquota exceeded (seg2 127.0.0.1:7004 pid=1970362) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- disable hardlimit and do some clean-ups -DROP TABLE IF EXISTS t1; -NOTICE: table "t1" does not exist, skipping -DROP TABLE IF EXISTS t2; -NOTICE: table "t2" does not exist, skipping -DROP TABLE IF EXISTS toast_table; -NOTICE: table "toast_table" does not exist, skipping -DROP TABLE IF EXISTS ao_table; -NOTICE: table "ao_table" does not exist, skipping -DROP TABLE IF EXISTS aocs_table; -NOTICE: table "aocs_table" does not exist, skipping -RESET search_path; -RESET default_tablespace; -DROP SCHEMA hardlimit_s; -DROP TABLESPACE ctas_schemaspc; -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null diff --git a/tests/regress/expected7/test_default_tablespace.out b/tests/regress/expected7/test_default_tablespace.out deleted file mode 100644 index d14251b5..00000000 --- a/tests/regress/expected7/test_default_tablespace.out +++ /dev/null @@ -1,186 +0,0 @@ --- test role_tablespace_quota works with tables/databases in default tablespace --- test role_tablespace_quota works with tables/databases in non-default tablespace with hard limits on --- start_ignore -\! mkdir -p /tmp/custom_tablespace --- end_ignore -DROP ROLE if EXISTS role1; -NOTICE: role "role1" does not exist, skipping -DROP ROLE if EXISTS role2; -NOTICE: role "role2" does not exist, skipping -CREATE ROLE role1 SUPERUSER; -CREATE ROLE role2 SUPERUSER; -SET ROLE role1; -DROP TABLE if EXISTS t; -NOTICE: table "t" does not exist, skipping -CREATE TABLE t (i int) DISTRIBUTED BY (i); --- with hard limits off -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.set_role_tablespace_quota('role1', 'pg_default', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert to success -INSERT INTO t SELECT generate_series(1, 100); -INSERT INTO t SELECT generate_series(1, 1000000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert to fail -INSERT INTO t SELECT generate_series(1, 1000000); -ERROR: tablespace: pg_default, role: role1 diskquota exceeded -SELECT r.rolname, t.spcname, b.target_type -FROM diskquota.rejectmap AS b, pg_tablespace AS t, pg_roles AS r -WHERE b.tablespace_oid = t.oid AND b.target_oid = r.oid AND r.rolname = 'role1' -ORDER BY r.rolname, t.spcname, b.target_type; - rolname | spcname | target_type ----------+------------+----------------------- - role1 | pg_default | ROLE_TABLESPACE_QUOTA -(1 row) - -DROP TABLE IF EXISTS t; -SELECT diskquota.set_role_tablespace_quota('role1', 'pg_default', '-1'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SET ROLE role2; -CREATE TABLE t (i int) DISTRIBUTED BY (i); --- with hard limits on -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.set_role_tablespace_quota('role2', 'pg_default', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert to fail because of hard limits -INSERT INTO t SELECT generate_series(1, 50000000); -ERROR: tablespace: 1663, role: 40739 diskquota exceeded (seg0 127.0.0.1:7002 pid=1971570) -DROP TABLE IF EXISTS t; -SET ROLE role1; --- database in customized tablespace -CREATE TABLESPACE custom_tablespace LOCATION '/tmp/custom_tablespace'; -CREATE DATABASE db_with_tablespace TABLESPACE custom_tablespace; -\c db_with_tablespace; -SET ROLE role1; -CREATE EXTENSION diskquota; --- with hard limits off -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.set_role_tablespace_quota('role1', 'custom_tablespace', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert to success -CREATE TABLE t_in_custom_tablespace (i) AS SELECT generate_series(1, 100) DISTRIBUTED BY (i); -INSERT INTO t_in_custom_tablespace SELECT generate_series(1, 1000000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert to fail -INSERT INTO t_in_custom_tablespace SELECT generate_series(1, 1000000); -ERROR: tablespace: custom_tablespace, role: role1 diskquota exceeded -SELECT r.rolname, t.spcname, b.target_type -FROM diskquota.rejectmap AS b, pg_tablespace AS t, pg_roles AS r -WHERE b.tablespace_oid = t.oid AND b.target_oid = r.oid AND r.rolname = 'role1' -ORDER BY r.rolname, t.spcname, b.target_type; - rolname | spcname | target_type ----------+-------------------+----------------------- - role1 | custom_tablespace | ROLE_TABLESPACE_QUOTA -(1 row) - -DROP TABLE IF EXISTS t_in_custom_tablespace; -SELECT diskquota.set_role_tablespace_quota('role1', 'custom_tablespace', '-1'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SET ROLE role2; --- with hard limits on -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.set_role_tablespace_quota('role2', 'custom_tablespace', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP TABLE IF EXISTS t_in_custom_tablespace; -NOTICE: table "t_in_custom_tablespace" does not exist, skipping --- expect insert to fail because of hard limits -CREATE TABLE t_in_custom_tablespace (i) AS SELECT generate_series(1, 50000000) DISTRIBUTED BY (i); -ERROR: tablespace: 40746, role: 40739 diskquota exceeded (seg2 127.0.0.1:7004 pid=1973467) --- clean up -DROP TABLE IF EXISTS t_in_custom_tablespace; -NOTICE: table "t_in_custom_tablespace" does not exist, skipping -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION IF EXISTS diskquota; -\c contrib_regression; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP DATABASE IF EXISTS db_with_tablespace; -DROP TABLESPACE IF EXISTS custom_tablespace; -RESET ROLE; -DROP ROLE IF EXISTS role1; -DROP ROLE IF EXISTS role2; diff --git a/tests/regress/expected7/test_delete_quota.out b/tests/regress/expected7/test_delete_quota.out deleted file mode 100644 index 967dd917..00000000 --- a/tests/regress/expected7/test_delete_quota.out +++ /dev/null @@ -1,37 +0,0 @@ --- Test delete disk quota -CREATE SCHEMA deleteschema; -SELECT diskquota.set_schema_quota('deleteschema', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO deleteschema; -CREATE TABLE c (i INT) DISTRIBUTED BY (i); --- expect failed -INSERT INTO c SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect fail -INSERT INTO c SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: deleteschema -SELECT diskquota.set_schema_quota('deleteschema', '-1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO c SELECT generate_series(1,100); -DROP TABLE c; -RESET search_path; -DROP SCHEMA deleteschema; diff --git a/tests/regress/expected7/test_drop_after_pause.out b/tests/regress/expected7/test_drop_after_pause.out deleted file mode 100644 index 24cbb191..00000000 --- a/tests/regress/expected7/test_drop_after_pause.out +++ /dev/null @@ -1,64 +0,0 @@ -CREATE DATABASE test_drop_after_pause; -\c test_drop_after_pause -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a SELECT generate_series(1,10000000); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: 25290 (seg2 127.0.0.1:7004 pid=1905198) -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE test_drop_after_pause; diff --git a/tests/regress/expected7/test_drop_extension.out b/tests/regress/expected7/test_drop_extension.out deleted file mode 100644 index b946654c..00000000 --- a/tests/regress/expected7/test_drop_extension.out +++ /dev/null @@ -1,13 +0,0 @@ -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; diff --git a/tests/regress/expected7/test_drop_table.out b/tests/regress/expected7/test_drop_table.out deleted file mode 100644 index d50db9e1..00000000 --- a/tests/regress/expected7/test_drop_table.out +++ /dev/null @@ -1,34 +0,0 @@ --- Test Drop table -CREATE SCHEMA sdrtbl; -SELECT diskquota.set_schema_quota('sdrtbl', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO sdrtbl; -CREATE TABLE a(i INT) DISTRIBUTED BY (i); -CREATE TABLE a2(i INT) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100); --- expect insert fail -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a2 SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: sdrtbl -DROP TABLE a; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO a2 SELECT generate_series(1,100); -DROP TABLE a2; -RESET search_path; -DROP SCHEMA sdrtbl; diff --git a/tests/regress/expected7/test_extension.out b/tests/regress/expected7/test_extension.out deleted file mode 100644 index fbd8483f..00000000 --- a/tests/regress/expected7/test_extension.out +++ /dev/null @@ -1,523 +0,0 @@ --- NOTE: when test this script, you must make sure that there is no diskquota --- worker process. -CREATE DATABASE dbx0 ; -CREATE DATABASE dbx1 ; -CREATE DATABASE dbx2 ; -CREATE DATABASE dbx3 ; -CREATE DATABASE dbx4 ; -CREATE DATABASE dbx5 ; -CREATE DATABASE dbx6 ; -CREATE DATABASE dbx7 ; -CREATE DATABASE dbx8 ; -CREATE DATABASE dbx9 ; -CREATE DATABASE dbx10 ; ---start_ignore -\! gpconfig -c diskquota.max_workers -v 20 --skipvalidation -20230117:12:50:10:1924108 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.max_workers -v 20 --skipvalidation' -\! gpstop -arf -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:12:50:11:1924636 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:12:50:12:1924636 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore -\c -show max_worker_processes; - max_worker_processes ----------------------- - 20 -(1 row) - -show diskquota.max_workers; - diskquota.max_workers ------------------------ - 20 -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\c dbx0 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx1 -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -INSERT INTO SX.a values(generate_series(0, 100000)); -CREATE EXTENSION diskquota; -WARNING: [diskquota] diskquota is not ready because current database is not empty -HINT: please run 'SELECT diskquota.init_table_size_table();' to initialize diskquota -SELECT diskquota.init_table_size_table(); - init_table_size_table ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx2 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx3 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx4 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx5 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx6 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx7 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx8 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE SCHEMA SX; -CREATE TABLE SX.a(i int) DISTRIBUTED BY (i); -SELECT diskquota.set_schema_quota('SX', '1MB'); - set_schema_quota ------------------- - -(1 row) - -INSERT INTO SX.a values(generate_series(0, 100000)); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO SX.a values(generate_series(0, 10)); -ERROR: schema's disk space quota exceeded with name: sx -DROP TABLE SX.a; -\c dbx9 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\c dbx10 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\c dbx0 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx1 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx2 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx3 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx4 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx5 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx6 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx7 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx8 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx9 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c dbx10 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE dbx0 ; -DROP DATABASE dbx1 ; -DROP DATABASE dbx2 ; -DROP DATABASE dbx3 ; -DROP DATABASE dbx4 ; -DROP DATABASE dbx5 ; -DROP DATABASE dbx6 ; -DROP DATABASE dbx7 ; -DROP DATABASE dbx8 ; -DROP DATABASE dbx9 ; -DROP DATABASE dbx10 ; ---start_ignore -\! gpconfig -c diskquota.max_workers -v 1 --skipvalidation -20230117:12:52:37:1941441 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.max_workers -v 1 --skipvalidation' -\! gpstop -arf; -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:12:52:37:1941981 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:12:52:38:1941981 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore -\c -show diskquota.max_workers; - diskquota.max_workers ------------------------ - 1 -(1 row) - diff --git a/tests/regress/expected7/test_fast_disk_check.out b/tests/regress/expected7/test_fast_disk_check.out deleted file mode 100644 index d883934f..00000000 --- a/tests/regress/expected7/test_fast_disk_check.out +++ /dev/null @@ -1,23 +0,0 @@ --- Test SCHEMA -CREATE SCHEMA s1; -SET search_path to s1; -CREATE TABLE a(i int) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,200000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT (pg_database_size(oid)-dbsize)/dbsize < 0.1 FROM pg_database, diskquota.show_fast_database_size_view WHERE datname='contrib_regression'; -WARNING: skipping "__gp_log_segment_ext" --- cannot calculate this foreign table size -WARNING: skipping "__gp_log_master_ext" --- cannot calculate this foreign table size -WARNING: skipping "gp_disk_free" --- cannot calculate this foreign table size - ?column? ----------- - f -(1 row) - -RESET search_path; -DROP TABLE s1.a; -DROP SCHEMA s1; diff --git a/tests/regress/expected7/test_fetch_table_stat.out b/tests/regress/expected7/test_fetch_table_stat.out deleted file mode 100644 index b9be7aec..00000000 --- a/tests/regress/expected7/test_fetch_table_stat.out +++ /dev/null @@ -1,35 +0,0 @@ --- --- 1. Test that when an error occurs in diskquota_fetch_table_stat --- the error message is preserved for us to debug. --- -CREATE TABLE t_error_handling (i int) DISTRIBUTED BY (i); --- Inject an error to a segment server, since this UDF is only called on segments. -SELECT gp_inject_fault_infinite('diskquota_fetch_table_stat', 'error', dbid) - FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Dispatch diskquota_fetch_table_stat to segments. --- There should be a warning message from segment server saying: --- fault triggered, fault name:'diskquota_fetch_table_stat' fault type:'error' --- We're not interested in the oid here, we aggregate the result by COUNT(*). -SELECT COUNT(*) - FROM (SELECT diskquota.diskquota_fetch_table_stat(1, array[(SELECT oid FROM pg_class WHERE relname='t_error_handling')]) - FROM gp_dist_random('gp_id') WHERE gp_segment_id=0) AS count; - count -------- - 1 -(1 row) - --- Reset the fault injector to prevent future failure. -SELECT gp_inject_fault_infinite('diskquota_fetch_table_stat', 'reset', dbid) - FROM gp_segment_configuration WHERE role='p' AND content=0; - gp_inject_fault_infinite --------------------------- - Success: -(1 row) - --- Do some clean-ups. -DROP TABLE t_error_handling; diff --git a/tests/regress/expected7/test_index.out b/tests/regress/expected7/test_index.out deleted file mode 100644 index a35ec4f9..00000000 --- a/tests/regress/expected7/test_index.out +++ /dev/null @@ -1,133 +0,0 @@ --- Test schema --- start_ignore -\! mkdir -p /tmp/indexspc --- end_ignore -CREATE SCHEMA indexschema1; -DROP TABLESPACE IF EXISTS indexspc; -NOTICE: tablespace "indexspc" does not exist, skipping -CREATE TABLESPACE indexspc LOCATION '/tmp/indexspc'; -SET search_path TO indexschema1; -CREATE TABLE test_index_a(i int) TABLESPACE indexspc DISTRIBUTED BY (i); -INSERT INTO test_index_a SELECT generate_series(1,20000); -SELECT diskquota.set_schema_tablespace_quota('indexschema1', 'indexspc','2 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes -FROM diskquota.show_fast_schema_tablespace_quota_view -WHERE schema_name='indexschema1' and tablespace_name='indexspc'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes ---------------+-----------------+-------------+----------------------------- - indexschema1 | indexspc | 2 | 1081344 -(1 row) - -SELECT tableid::regclass, size, segid -FROM diskquota.table_size -WHERE tableid = 'test_index_a'::regclass -ORDER BY segid; - tableid | size | segid ---------------+---------+------- - test_index_a | 1081344 | -1 - test_index_a | 360448 | 0 - test_index_a | 360448 | 1 - test_index_a | 360448 | 2 -(4 rows) - --- create index for the table, index in default tablespace -CREATE INDEX a_index ON test_index_a(i); -INSERT INTO test_index_a SELECT generate_series(1,10000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO test_index_a SELECT generate_series(1,100); -SELECT schema_name,tablespace_name,quota_in_mb,nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view WHERE schema_name ='indexschema1' and tablespace_name='indexspc'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes ---------------+-----------------+-------------+----------------------------- - indexschema1 | indexspc | 2 | 1441792 -(1 row) - -SELECT tableid::regclass, size, segid -FROM diskquota.table_size -WHERE tableid = 'test_index_a'::regclass -ORDER BY segid; - tableid | size | segid ---------------+---------+------- - test_index_a | 1441792 | -1 - test_index_a | 491520 | 0 - test_index_a | 491520 | 1 - test_index_a | 458752 | 2 -(4 rows) - -SELECT tableid::regclass, size, segid -FROM diskquota.table_size -WHERE tableid = 'a_index'::regclass -ORDER BY segid; - tableid | size | segid ----------+---------+------- - a_index | 1212416 | -1 - a_index | 393216 | 0 - a_index | 393216 | 1 - a_index | 393216 | 2 -(4 rows) - --- add index to tablespace indexspc -ALTER index a_index SET TABLESPACE indexspc; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT schema_name,tablespace_name,quota_in_mb,nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view WHERE schema_name ='indexschema1' and tablespace_name='indexspc'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes ---------------+-----------------+-------------+----------------------------- - indexschema1 | indexspc | 2 | 2654208 -(1 row) - -SELECT size, segid FROM diskquota.table_size , pg_class where tableid=oid and (relname='test_index_a' or relname='a_index') and segid=-1; - size | segid ----------+------- - 1212416 | -1 - 1441792 | -1 -(2 rows) - --- expect insert fail -INSERT INTO test_index_a SELECT generate_series(1,100); -ERROR: tablespace: indexspc, schema: indexschema1 diskquota exceeded --- index tablespace quota exceeded -ALTER table test_index_a SET TABLESPACE pg_default; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO test_index_a SELECT generate_series(1,100); -INSERT INTO test_index_a SELECT generate_series(1,200000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO test_index_a SELECT generate_series(1,100); -ERROR: tablespace: indexspc, schema: indexschema1 diskquota exceeded -RESET search_path; -DROP INDEX indexschema1.a_index; -DROP TABLE indexschema1.test_index_a; -DROP SCHEMA indexschema1; -DROP TABLESPACE indexspc; diff --git a/tests/regress/expected7/test_many_active_tables.out b/tests/regress/expected7/test_many_active_tables.out deleted file mode 100644 index f3298c1c..00000000 --- a/tests/regress/expected7/test_many_active_tables.out +++ /dev/null @@ -1,31 +0,0 @@ -CREATE TABLE t1 (pk int, val int) -DISTRIBUTED BY (pk) -PARTITION BY RANGE (pk) (START (1) END (1000) EVERY (1)); -INSERT INTO t1 -SELECT pk, val -FROM generate_series(1, 10000) AS val, generate_series(1, 999) AS pk; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT count(*) >= 999 FROM diskquota.table_size WHERE size > 0; - ?column? ----------- - t -(1 row) - -DROP TABLE t1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT count(*) < 999 FROM diskquota.table_size WHERE size > 0; - ?column? ----------- - t -(1 row) - diff --git a/tests/regress/expected7/test_mistake.out b/tests/regress/expected7/test_mistake.out deleted file mode 100644 index fab4c6eb..00000000 --- a/tests/regress/expected7/test_mistake.out +++ /dev/null @@ -1,34 +0,0 @@ --- to make sure that the schema 'notfoundns' is really not found -select nspname from pg_namespace where nspname = 'notfoundns'; - nspname ---------- -(0 rows) - -select diskquota.set_schema_quota('notfoundns', '1 MB'); -ERROR: schema "notfoundns" does not exist -DROP SCHEMA IF EXISTS nmistake; -NOTICE: schema "nmistake" does not exist, skipping -CREATE SCHEMA nmistake; -select diskquota.set_schema_quota('nmistake', '0 MB'); -ERROR: disk quota can not be set to 0 MB -DROP ROLE IF EXISTS rmistake; -NOTICE: role "rmistake" does not exist, skipping -CREATE ROLE rmistake; -NOTICE: resource queue required -- using default resource queue "pg_default" -select diskquota.set_role_quota('rmistake', '0 MB'); -ERROR: disk quota can not be set to 0 MB --- start_ignore -\! mkdir -p /tmp/spcmistake --- end_ignore -DROP TABLESPACE IF EXISTS spcmistake; -NOTICE: tablespace "spcmistake" does not exist, skipping -CREATE TABLESPACE spcmistake LOCATION '/tmp/spcmistake'; -SELECT diskquota.set_schema_tablespace_quota('nmistake', 'spcmistake','0 MB'); -ERROR: disk quota can not be set to 0 MB -SELECT diskquota.set_role_tablespace_quota('rmistake', 'spcmistake','0 MB'); -ERROR: disk quota can not be set to 0 MB -SELECT diskquota.set_per_segment_quota('spcmistake', 0); -ERROR: per segment quota ratio can not be set to 0 -DROP SCHEMA nmistake; -DROP ROLE rmistake; -DROP TABLESPACE spcmistake; diff --git a/tests/regress/expected7/test_partition.out b/tests/regress/expected7/test_partition.out deleted file mode 100644 index 322c00c6..00000000 --- a/tests/regress/expected7/test_partition.out +++ /dev/null @@ -1,63 +0,0 @@ --- Test partition table -CREATE SCHEMA s8; -SELECT diskquota.SET_schema_quota('s8', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO s8; -CREATE TABLE measurement ( - city_id int not null, - logdate date not null, - peaktemp int, - unitsales int -)PARTITION BY RANGE (logdate) -( - PARTITION Feb06 START (date '2006-02-01') INCLUSIVE, - PARTITION Mar06 START (date '2006-03-01') INCLUSIVE - END (date '2016-04-01') EXCLUSIVE -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'city_id' 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. -INSERT INTO measurement SELECT generate_series(1,100), '2006-02-02' ,1,1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO measurement SELECT 1, '2006-02-02' ,1,1; --- expect insert fail -INSERT INTO measurement SELECT generate_series(1,100000), '2006-03-02' ,1,1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO measurement SELECT 1, '2006-02-02' ,1,1; -ERROR: schema's disk space quota exceeded with name: s8 --- expect insert fail -INSERT INTO measurement SELECT 1, '2006-03-03' ,1,1; -ERROR: schema's disk space quota exceeded with name: s8 -DELETE FROM measurement WHERE logdate='2006-03-02'; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -VACUUM FULL measurement; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO measurement SELECT 1, '2006-02-02' ,1,1; -INSERT INTO measurement SELECT 1, '2006-03-03' ,1,1; -DROP TABLE measurement; -RESET search_path; -DROP SCHEMA s8; diff --git a/tests/regress/expected7/test_pause_and_resume.out b/tests/regress/expected7/test_pause_and_resume.out deleted file mode 100644 index 18ae2573..00000000 --- a/tests/regress/expected7/test_pause_and_resume.out +++ /dev/null @@ -1,70 +0,0 @@ --- Test pause and resume. -CREATE SCHEMA s1; -SET search_path TO s1; -CREATE TABLE a(i int) DISTRIBUTED BY (i); --- expect insert succeed -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.set_schema_quota('s1', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: s1 --- pause extension -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size -WHERE tableid = 'a'::regclass AND segid = -1; - tableid | size | segid ----------+---------+------- - a | 3932160 | -1 -(1 row) - --- expect insert succeed -INSERT INTO a SELECT generate_series(1,100000); --- resume extension -SELECT diskquota.resume(); - resume --------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: s1 --- table size should be updated after resume -SELECT tableid::regclass, size, segid FROM diskquota.table_size -WHERE tableid = 'a'::regclass AND segid = -1; - tableid | size | segid ----------+---------+------- - a | 7569408 | -1 -(1 row) - -RESET search_path; -DROP TABLE s1.a; -DROP SCHEMA s1; diff --git a/tests/regress/expected7/test_pause_and_resume_multiple_db.out b/tests/regress/expected7/test_pause_and_resume_multiple_db.out deleted file mode 100644 index ed211216..00000000 --- a/tests/regress/expected7/test_pause_and_resume_multiple_db.out +++ /dev/null @@ -1,201 +0,0 @@ --- need 'contrib_regression' as test database -\c -CREATE SCHEMA s1; -SET search_path TO s1; -CREATE DATABASE test_pause_and_resume; -CREATE DATABASE test_new_create_database; -\c test_pause_and_resume -CREATE SCHEMA s1; -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\c contrib_regression -CREATE TABLE s1.a(i int) DISTRIBUTED BY (i); -INSERT INTO s1.a SELECT generate_series(1,100000); -- expect insert succeed -\c test_pause_and_resume -CREATE TABLE s1.a(i int) DISTRIBUTED BY (i); -INSERT INTO s1.a SELECT generate_series(1,100000); -- expect insert succeed -\c contrib_regression -SELECT diskquota.set_schema_quota('s1', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: s1 -\c test_pause_and_resume -SELECT diskquota.set_schema_quota('s1', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: s1 -\c contrib_regression -SELECT diskquota.pause(); -- pause extension, onle effect current database - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 's1.a'::regclass AND segid = -1; - tableid | size | segid ----------+---------+------- - s1.a | 3932160 | -1 -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert succeed -\c test_pause_and_resume -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 's1.a'::regclass AND segid = -1; - tableid | size | segid ----------+---------+------- - s1.a | 3932160 | -1 -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: s1 -SELECT diskquota.pause(); -- pause extension, onle effect current database - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 's1.a'::regclass AND segid = -1; - tableid | size | segid ----------+---------+------- - s1.a | 3932160 | -1 -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert succeed -\c test_new_create_database; -CREATE SCHEMA s1; -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); -- new database should be active although other database is paused - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE TABLE s1.a(i int) DISTRIBUTED BY (i); -INSERT INTO s1.a SELECT generate_series(1,100000); -- expect insert succeed -SELECT diskquota.set_schema_quota('s1', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100000); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: s1 -SELECT diskquota.pause(); -- pause extension, onle effect current database - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert succeed --- resume should onle effect current database -SELECT diskquota.resume(); - resume --------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: s1 -\c contrib_regression -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert succeed -SELECT diskquota.resume(); - resume --------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO s1.a SELECT generate_series(1,100); -- expect insert fail -ERROR: schema's disk space quota exceeded with name: s1 -\c test_pause_and_resume -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c test_new_create_database -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP SCHEMA s1 CASCADE; -NOTICE: drop cascades to table s1.a -DROP DATABASE test_pause_and_resume; -DROP DATABASE test_new_create_database; diff --git a/tests/regress/expected7/test_primary_failure.out b/tests/regress/expected7/test_primary_failure.out deleted file mode 100644 index 4e3ffa18..00000000 --- a/tests/regress/expected7/test_primary_failure.out +++ /dev/null @@ -1,126 +0,0 @@ -CREATE SCHEMA ftsr; -SELECT diskquota.set_schema_quota('ftsr', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO ftsr; -create or replace language plpythonu; -ERROR: could not access file "$libdir/plpython2": No such file or directory --- --- pg_ctl: --- datadir: data directory of process to target with `pg_ctl` --- command: commands valid for `pg_ctl` --- command_mode: modes valid for `pg_ctl -m` --- -create or replace function pg_ctl(datadir text, command text, command_mode text default 'immediate') -returns text as $$ - import subprocess - if command not in ('stop', 'restart'): - return 'Invalid command input' - - cmd = 'pg_ctl -l postmaster.log -D %s ' % datadir - cmd = cmd + '-W -m %s %s' % (command_mode, command) - - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') -$$ language plpythonu; -ERROR: language "plpythonu" does not exist -HINT: Use CREATE EXTENSION to load the language into the database. -create or replace function pg_recoverseg(datadir text, command text) -returns text as $$ - import subprocess - cmd = 'gprecoverseg -%s -d %s; exit 0; ' % (command, datadir) - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') -$$ language plpythonu; -ERROR: language "plpythonu" does not exist -HINT: Use CREATE EXTENSION to load the language into the database. -CREATE TABLE a(i int) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100); -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: ftsr --- now one of primary is down -select pg_ctl((select datadir from gp_segment_configuration c where c.role='p' and c.content=0), 'stop'); -ERROR: function pg_ctl(text, unknown) does not exist -LINE 1: select pg_ctl((select datadir from gp_segment_configuration ... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- switch mirror to primary -select gp_request_fts_probe_scan(); - gp_request_fts_probe_scan ---------------------------- - t -(1 row) - --- check GPDB status -select content, preferred_role, role, status, mode from gp_segment_configuration where content = 0; - content | preferred_role | role | status | mode ----------+----------------+------+--------+------ - 0 | p | p | u | s - 0 | m | m | u | s -(2 rows) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: ftsr --- increase quota -SELECT diskquota.set_schema_quota('ftsr', '200 MB'); - set_schema_quota ------------------- - -(1 row) - --- pull up failed primary --- start_ignore -select pg_recoverseg((select datadir from gp_segment_configuration c where c.role='p' and c.content=-1), 'a'); -ERROR: function pg_recoverseg(text, unknown) does not exist -LINE 1: select pg_recoverseg((select datadir from gp_segment_configu... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. -select pg_recoverseg((select datadir from gp_segment_configuration c where c.role='p' and c.content=-1), 'ar'); -ERROR: function pg_recoverseg(text, unknown) does not exist -LINE 1: select pg_recoverseg((select datadir from gp_segment_configu... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. -select pg_recoverseg((select datadir from gp_segment_configuration c where c.role='p' and c.content=-1), 'a'); -ERROR: function pg_recoverseg(text, unknown) does not exist -LINE 1: select pg_recoverseg((select datadir from gp_segment_configu... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. -select pg_recoverseg((select datadir from gp_segment_configuration c where c.role='p' and c.content=-1), 'ar'); -ERROR: function pg_recoverseg(text, unknown) does not exist -LINE 1: select pg_recoverseg((select datadir from gp_segment_configu... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- check GPDB status -select content, preferred_role, role, status, mode from gp_segment_configuration where content = 0; - content | preferred_role | role | status | mode ----------+----------------+------+--------+------ - 0 | p | p | u | s - 0 | m | m | u | s -(2 rows) - --- end_ignore -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT quota_in_mb, nspsize_in_bytes from diskquota.show_fast_schema_quota_view where schema_name='ftsr'; - quota_in_mb | nspsize_in_bytes --------------+------------------ - 200 | 3932160 -(1 row) - -INSERT INTO a SELECT generate_series(1,100); -DROP TABLE a; -DROP SCHEMA ftsr CASCADE; diff --git a/tests/regress/expected7/test_quota_view_no_table.out b/tests/regress/expected7/test_quota_view_no_table.out deleted file mode 100644 index 27a0b315..00000000 --- a/tests/regress/expected7/test_quota_view_no_table.out +++ /dev/null @@ -1,64 +0,0 @@ -CREATE ROLE no_table SUPERUSER; -CREATE SCHEMA no_table; -SELECT diskquota.set_schema_quota('no_table', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT schema_name, quota_in_mb, nspsize_in_bytes -FROM diskquota.show_fast_schema_quota_view; - schema_name | quota_in_mb | nspsize_in_bytes --------------+-------------+------------------ - no_table | 1 | 0 -(1 row) - -SELECT diskquota.set_role_quota('no_table', '1 MB'); - set_role_quota ----------------- - -(1 row) - -SELECT role_name, quota_in_mb, rolsize_in_bytes -FROM diskquota.show_fast_role_quota_view; - role_name | quota_in_mb | rolsize_in_bytes ------------+-------------+------------------ - no_table | 1 | 0 -(1 row) - -SELECT diskquota.set_schema_tablespace_quota('no_table', 'pg_default', '1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes -FROM diskquota.show_fast_schema_tablespace_quota_view; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes --------------+-----------------+-------------+----------------------------- - no_table | pg_default | 1 | 0 -(1 row) - -SELECT diskquota.set_role_tablespace_quota('no_table', 'pg_default', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT role_name, tablespace_name , quota_in_mb, rolsize_tablespace_in_bytes -FROM diskquota.show_fast_role_tablespace_quota_view; - role_name | tablespace_name | quota_in_mb | rolsize_tablespace_in_bytes ------------+-----------------+-------------+----------------------------- - no_table | pg_default | 1 | 0 -(1 row) - -DROP ROLE no_table; -DROP SCHEMA no_table; --- Wait until the quota configs are removed from the memory --- automatically after DROP. -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - diff --git a/tests/regress/expected7/test_readiness_logged.out b/tests/regress/expected7/test_readiness_logged.out deleted file mode 100644 index c798f08b..00000000 --- a/tests/regress/expected7/test_readiness_logged.out +++ /dev/null @@ -1,38 +0,0 @@ -CREATE DATABASE test_readiness_logged; -\c test_readiness_logged -CREATE TABLE t (i int) DISTRIBUTED BY (i); -CREATE EXTENSION diskquota; -WARNING: [diskquota] diskquota is not ready because current database is not empty -HINT: please run 'SELECT diskquota.init_table_size_table();' to initialize diskquota -CREATE EXTENSION diskquota_test; -SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY'');'); - wait ------- - t -(1 row) - -SELECT count(*) FROM gp_toolkit.gp_log_database -WHERE logmessage = '[diskquota] diskquota is not ready'; - count -------- - 1 -(1 row) - -\! gpstop -raf > /dev/null -\c -SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY'');'); - wait ------- - t -(1 row) - -SELECT count(*) FROM gp_toolkit.gp_log_database -WHERE logmessage = '[diskquota] diskquota is not ready'; - count -------- - 2 -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE test_readiness_logged; diff --git a/tests/regress/expected7/test_recreate.out b/tests/regress/expected7/test_recreate.out deleted file mode 100644 index c69cd82e..00000000 --- a/tests/regress/expected7/test_recreate.out +++ /dev/null @@ -1,27 +0,0 @@ -\c -CREATE DATABASE test_recreate; -\c diskquota -INSERT INTO diskquota_namespace.database_list(dbid) SELECT oid FROM pg_database WHERE datname = 'test_recreate'; -\c test_recreate -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); -- shoud be ok - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE test_recreate; diff --git a/tests/regress/expected7/test_rejectmap_mul_db.out b/tests/regress/expected7/test_rejectmap_mul_db.out deleted file mode 100644 index 89142d8b..00000000 --- a/tests/regress/expected7/test_rejectmap_mul_db.out +++ /dev/null @@ -1,79 +0,0 @@ --- 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'); - 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:8003 pid=43782) --- 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 (seg0 127.0.0.1:7002 pid=1961759) -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(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 -\! 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; diff --git a/tests/regress/expected7/test_relation_size.out b/tests/regress/expected7/test_relation_size.out deleted file mode 100644 index 27b4a4eb..00000000 --- a/tests/regress/expected7/test_relation_size.out +++ /dev/null @@ -1,99 +0,0 @@ -CREATE TEMP TABLE t1(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. -INSERT INTO t1 SELECT generate_series(1, 10000); -SELECT diskquota.relation_size('t1'); - relation_size ---------------- - 688128 -(1 row) - -SELECT pg_table_size('t1'); - pg_table_size ---------------- - 688128 -(1 row) - -CREATE TABLE t2(i int) DISTRIBUTED BY (i); -INSERT INTO t2 SELECT generate_series(1, 10000); -SELECT diskquota.relation_size('t2'); - relation_size ---------------- - 688128 -(1 row) - -SELECT pg_table_size('t2'); - pg_table_size ---------------- - 688128 -(1 row) - --- start_ignore -\! mkdir -p /tmp/test_spc --- end_ignore -DROP TABLESPACE IF EXISTS test_spc; -NOTICE: tablespace "test_spc" does not exist, skipping -CREATE TABLESPACE test_spc LOCATION '/tmp/test_spc'; -ALTER TABLE t1 SET TABLESPACE test_spc; -INSERT INTO t1 SELECT generate_series(1, 10000); -SELECT diskquota.relation_size('t1'); - relation_size ---------------- - 1081344 -(1 row) - -SELECT pg_table_size('t1'); - pg_table_size ---------------- - 1081344 -(1 row) - -ALTER TABLE t2 SET TABLESPACE test_spc; -INSERT INTO t2 SELECT generate_series(1, 10000); -SELECT diskquota.relation_size('t2'); - relation_size ---------------- - 1081344 -(1 row) - -SELECT pg_table_size('t2'); - pg_table_size ---------------- - 1081344 -(1 row) - -DROP TABLE t1, t2; -DROP TABLESPACE test_spc; --- start_ignore -\! rm -rf /tmp/test_spc - -- end_ignore -CREATE TABLE ao (i int) WITH (appendonly=true) DISTRIBUTED BY (i); -INSERT INTO ao SELECT generate_series(1, 10000); -SELECT diskquota.relation_size('ao'); - relation_size ---------------- - 100200 -(1 row) - -SELECT pg_relation_size('ao'); - pg_relation_size ------------------- - 100200 -(1 row) - -DROP TABLE ao; -CREATE TABLE aocs (i int, t text) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (i); -INSERT INTO aocs SELECT i, repeat('a', 1000) FROM generate_series(1, 10000) AS i; -SELECT diskquota.relation_size('aocs'); - relation_size ---------------- - 10092696 -(1 row) - -SELECT pg_relation_size('aocs'); - pg_relation_size ------------------- - 10092696 -(1 row) - -DROP TABLE aocs; diff --git a/tests/regress/expected7/test_rename.out b/tests/regress/expected7/test_rename.out deleted file mode 100644 index 1e9ab7ae..00000000 --- a/tests/regress/expected7/test_rename.out +++ /dev/null @@ -1,71 +0,0 @@ --- test rename schema -CREATE SCHEMA srs1; -SELECT diskquota.set_schema_quota('srs1', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -set search_path to srs1; -CREATE TABLE a(i int) DISTRIBUTED BY (i); --- expect insert fail -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: srs1 -ALTER SCHEMA srs1 RENAME TO srs2; -SET search_path TO srs2; --- expect insert fail -INSERT INTO a SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: srs2 --- test rename table -ALTER TABLE a RENAME TO a2; --- expect insert fail -INSERT INTO a2 SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: srs2 -DROP TABLE a2; -RESET search_path; -DROP SCHEMA srs2; --- test rename role -CREATE SCHEMA srr1; -CREATE ROLE srerole NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -SELECT diskquota.set_role_quota('srerole', '1MB'); - set_role_quota ----------------- - -(1 row) - -SET search_path TO srr1; -CREATE TABLE a(i int) DISTRIBUTED BY (i); -ALTER TABLE a OWNER TO srerole; --- expect insert fail -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,10); -ERROR: role's disk space quota exceeded with name: srerole -ALTER ROLE srerole RENAME TO srerole2; --- expect insert fail -INSERT INTO a SELECT generate_series(1,10); -ERROR: role's disk space quota exceeded with name: srerole2 --- test rename table -ALTER TABLE a RENAME TO a2; --- expect insert fail -INSERT INTO a2 SELECT generate_series(1,10); -ERROR: role's disk space quota exceeded with name: srerole2 -DROP TABLE a2; -DROP ROLE srerole2; -RESET search_path; -DROP SCHEMA srr1; diff --git a/tests/regress/expected7/test_reschema.out b/tests/regress/expected7/test_reschema.out deleted file mode 100644 index 6b88a808..00000000 --- a/tests/regress/expected7/test_reschema.out +++ /dev/null @@ -1,39 +0,0 @@ --- Test re-set_schema_quota -CREATE SCHEMA srE; -SELECT diskquota.set_schema_quota('srE', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO srE; -CREATE TABLE a(i int) DISTRIBUTED BY (i); --- expect insert fail -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail when exceed quota limit -INSERT INTO a SELECT generate_series(1,1000); -ERROR: schema's disk space quota exceeded with name: sre --- set schema quota larger -SELECT diskquota.set_schema_quota('srE', '1 GB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO a SELECT generate_series(1,1000); -DROP TABLE a; -RESET search_path; -DROP SCHEMA srE; diff --git a/tests/regress/expected7/test_role.out b/tests/regress/expected7/test_role.out deleted file mode 100644 index e51d4685..00000000 --- a/tests/regress/expected7/test_role.out +++ /dev/null @@ -1,138 +0,0 @@ --- Test role quota -CREATE SCHEMA srole; -SET search_path TO srole; -CREATE ROLE u1 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE ROLE u2 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); -ALTER TABLE b OWNER TO u1; -CREATE TABLE b2 (t TEXT) DISTRIBUTED BY (t); -ALTER TABLE b2 OWNER TO u1; -SELECT diskquota.set_role_quota('u1', '1 MB'); - set_role_quota ----------------- - -(1 row) - -INSERT INTO b SELECT generate_series(1,100); --- expect insert success -INSERT INTO b SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: role's disk space quota exceeded with name: u1 --- expect insert fail -INSERT INTO b2 SELECT generate_series(1,100); -ERROR: role's disk space quota exceeded with name: u1 --- Delete role quota -SELECT diskquota.set_role_quota('u1', '-1 MB'); - set_role_quota ----------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); --- Reset role quota -SELECT diskquota.set_role_quota('u1', '1 MB'); - set_role_quota ----------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: role's disk space quota exceeded with name: u1 -SELECT role_name, quota_in_mb, rolsize_in_bytes FROM diskquota.show_fast_role_quota_view WHERE role_name='u1'; - role_name | quota_in_mb | rolsize_in_bytes ------------+-------------+------------------ - u1 | 1 | 4194304 -(1 row) - -SELECT tableid::regclass, size, segid -FROM diskquota.table_size -WHERE tableid = 'b'::regclass -ORDER BY segid; - tableid | size | segid ----------+---------+------- - b | 4063232 | -1 - b | 1343488 | 0 - b | 1343488 | 1 - b | 1343488 | 2 -(4 rows) - -SELECT tableid::regclass, size, segid -FROM diskquota.table_size -WHERE tableid = 'b2'::regclass -ORDER BY segid; - tableid | size | segid ----------+--------+------- - b2 | 131072 | -1 - b2 | 32768 | 0 - b2 | 32768 | 1 - b2 | 32768 | 2 -(4 rows) - -ALTER TABLE b OWNER TO u2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO b SELECT generate_series(1,100); --- expect insert succeed -INSERT INTO b2 SELECT generate_series(1,100); --- superuser is blocked to set quota ---start_ignore -SELECT rolname from pg_roles where rolsuper=true; - rolname ---------- - zhrt -(1 row) - ---end_ignore -\gset -select diskquota.set_role_quota(:'rolname', '1mb'); -ERROR: Can not set disk quota for system owner: zhrt -select diskquota.set_role_quota(:'rolname', '-1mb'); - set_role_quota ----------------- - -(1 row) - -CREATE ROLE "Tn" NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -SELECT diskquota.set_role_quota('Tn', '-1 MB'); -- fail -ERROR: role "tn" does not exist -SELECT diskquota.set_role_quota('"tn"', '-1 MB'); -- fail -ERROR: role "tn" does not exist -SELECT diskquota.set_role_quota('"Tn"', '-1 MB'); - set_role_quota ----------------- - -(1 row) - -DROP TABLE b, b2; -DROP ROLE u1, u2, "Tn"; -RESET search_path; -DROP SCHEMA srole; diff --git a/tests/regress/expected7/test_schema.out b/tests/regress/expected7/test_schema.out deleted file mode 100644 index 866b4b3e..00000000 --- a/tests/regress/expected7/test_schema.out +++ /dev/null @@ -1,109 +0,0 @@ --- Test schema -CREATE SCHEMA s1; -SET search_path TO s1; -CREATE TABLE a(i int) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100); --- expect insert success -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.set_schema_quota('s1', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: s1 -CREATE TABLE a2(i int) DISTRIBUTED BY (i); --- expect insert fail -INSERT INTO a2 SELECT generate_series(1,100); -ERROR: schema's disk space quota exceeded with name: s1 --- Test alter table set schema -CREATE SCHEMA s2; -ALTER TABLE s1.a SET SCHEMA s2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO a2 SELECT generate_series(1,200); --- expect insert succeed -INSERT INTO s2.a SELECT generate_series(1,200); --- prepare a schema that has reached quota limit -CREATE SCHEMA badquota; -DROP ROLE IF EXISTS testbody; -NOTICE: role "testbody" does not exist, skipping -CREATE ROLE testbody; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE TABLE badquota.t1(i INT) DISTRIBUTED BY (i); -ALTER TABLE badquota.t1 OWNER TO testbody; -INSERT INTO badquota.t1 SELECT generate_series(0, 100000); -SELECT diskquota.init_table_size_table(); - init_table_size_table ------------------------ - -(1 row) - -SELECT diskquota.set_schema_quota('badquota', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT size, segid FROM diskquota.table_size - WHERE tableid IN (SELECT oid FROM pg_class WHERE relname='t1') - ORDER BY segid DESC; - size | segid ----------+------- - 1310720 | 2 - 1310720 | 1 - 1310720 | 0 - 3932160 | -1 -(4 rows) - --- expect fail -INSERT INTO badquota.t1 SELECT generate_series(0, 10); -ERROR: schema's disk space quota exceeded with name: badquota -ALTER TABLE s2.a SET SCHEMA badquota; --- expect failed -INSERT INTO badquota.a SELECT generate_series(0, 100); -ERROR: schema's disk space quota exceeded with name: badquota -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT schema_name, quota_in_mb FROM diskquota.show_fast_schema_quota_view WHERE schema_name = 's1'; - schema_name | quota_in_mb --------------+------------- - s1 | 1 -(1 row) - -CREATE SCHEMA "Tn1"; -SELECT diskquota.set_schema_quota('"Tn1"', '-1 MB'); - set_schema_quota ------------------- - -(1 row) - -RESET search_path; -DROP TABLE s1.a2, badquota.a; -DROP SCHEMA s1, s2, "Tn1"; -DROP TABLE badquota.t1; -DROP ROLE testbody; -DROP SCHEMA badquota; diff --git a/tests/regress/expected7/test_show_status.out b/tests/regress/expected7/test_show_status.out deleted file mode 100644 index 14c3e7de..00000000 --- a/tests/regress/expected7/test_show_status.out +++ /dev/null @@ -1,67 +0,0 @@ -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | on - hard limits | off -(2 rows) - -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | on - hard limits | on -(2 rows) - -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | on - hard limits | off -(2 rows) - -select from diskquota.pause(); --- -(1 row) - -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | paused - hard limits | off -(2 rows) - -\! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null -\! gpstop -u > /dev/null -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | paused - hard limits | paused -(2 rows) - -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | paused - hard limits | off -(2 rows) - -select from diskquota.resume(); --- -(1 row) - -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! gpstop -u > /dev/null -select * from diskquota.status() where name not like '%version'; - name | status --------------+-------- - soft limits | on - hard limits | off -(2 rows) - diff --git a/tests/regress/expected7/test_tablespace_diff_schema.out b/tests/regress/expected7/test_tablespace_diff_schema.out deleted file mode 100644 index 93da486b..00000000 --- a/tests/regress/expected7/test_tablespace_diff_schema.out +++ /dev/null @@ -1,87 +0,0 @@ --- allow set quota for different schema in the same tablespace --- delete quota for one schema will not drop other quotas with different schema in the same tablespace --- start_ignore -\! mkdir -p /tmp/spc_diff_schema --- end_ignore -CREATE TABLESPACE spc_diff_schema LOCATION '/tmp/spc_diff_schema'; -CREATE SCHEMA schema_in_tablespc; -SET search_path TO schema_in_tablespc; -CREATE TABLE a(i int) TABLESPACE spc_diff_schema DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100); -SELECT diskquota.set_schema_tablespace_quota('schema_in_tablespc', 'spc_diff_schema','1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- with hardlimits off, expect to success -INSERT INTO a SELECT generate_series(1,1000000); --- wait for next loop for bgworker to add it to rejectmap -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect to fail -INSERT INTO a SELECT generate_series(1,1000000); -ERROR: tablespace: spc_diff_schema, schema: schema_in_tablespc diskquota exceeded -SELECT schema_name, tablespace_name FROM diskquota.show_fast_schema_tablespace_quota_view; - schema_name | tablespace_name ---------------------+----------------- - schema_in_tablespc | spc_diff_schema -(1 row) - -SELECT diskquota.set_schema_tablespace_quota('schema_in_tablespc', 'pg_default','1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT schema_name, tablespace_name FROM diskquota.show_fast_schema_tablespace_quota_view; - schema_name | tablespace_name ---------------------+----------------- - schema_in_tablespc | spc_diff_schema - schema_in_tablespc | pg_default -(2 rows) - -SELECT diskquota.set_schema_tablespace_quota('schema_in_tablespc', 'pg_default','-1'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT schema_name, tablespace_name FROM diskquota.show_fast_schema_tablespace_quota_view; - schema_name | tablespace_name ---------------------+----------------- - schema_in_tablespc | spc_diff_schema -(1 row) - --- expect to fail -INSERT INTO a SELECT generate_series(1,1000000); -ERROR: tablespace: spc_diff_schema, schema: schema_in_tablespc diskquota exceeded -reset search_path; -DROP TABLE IF EXISTS schema_in_tablespc.a; -DROP tablespace IF EXISTS spc_diff_schema; -DROP SCHEMA IF EXISTS schema_in_tablespc; --- start_ignore -\! rmdir /tmp/spc_diff_schema - -- end_ignore diff --git a/tests/regress/expected7/test_tablespace_role.out b/tests/regress/expected7/test_tablespace_role.out deleted file mode 100644 index b926890b..00000000 --- a/tests/regress/expected7/test_tablespace_role.out +++ /dev/null @@ -1,194 +0,0 @@ --- Test role quota --- start_ignore -\! mkdir -p /tmp/rolespc --- end_ignore -DROP TABLESPACE IF EXISTS rolespc; -NOTICE: tablespace "rolespc" does not exist, skipping -CREATE TABLESPACE rolespc LOCATION '/tmp/rolespc'; -CREATE SCHEMA rolespcrole; -SET search_path TO rolespcrole; -DROP ROLE IF EXISTS rolespcu1; -NOTICE: role "rolespcu1" does not exist, skipping -DROP ROLE IF EXISTS rolespcu2; -NOTICE: role "rolespcu2" does not exist, skipping -CREATE ROLE rolespcu1 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE ROLE rolespcu2 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE TABLE b (t TEXT) TABLESPACE rolespc DISTRIBUTED BY (t); -CREATE TABLE b2 (t TEXT) TABLESPACE rolespc DISTRIBUTED BY (t); -ALTER TABLE b2 OWNER TO rolespcu1; -INSERT INTO b SELECT generate_series(1,100); --- expect insert success -INSERT INTO b SELECT generate_series(1,100000); -SELECT diskquota.set_role_tablespace_quota('rolespcu1', 'rolespc', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); -ALTER TABLE b OWNER TO rolespcu1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc, role: rolespcu1 diskquota exceeded --- expect insert fail -INSERT INTO b2 SELECT generate_series(1,100); -ERROR: tablespace: rolespc, role: rolespcu1 diskquota exceeded --- Test show_fast_role_tablespace_quota_view -SELECT role_name, tablespace_name, quota_in_mb, rolsize_tablespace_in_bytes FROM diskquota.show_fast_role_tablespace_quota_view WHERE role_name = 'rolespcu1' and tablespace_name = 'rolespc'; - role_name | tablespace_name | quota_in_mb | rolsize_tablespace_in_bytes ------------+-----------------+-------------+----------------------------- - rolespcu1 | rolespc | 1 | 4194304 -(1 row) - --- Test alter owner -ALTER TABLE b OWNER TO rolespcu2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO b SELECT generate_series(1,100); --- expect insert succeed -INSERT INTO b2 SELECT generate_series(1,100); -ALTER TABLE b OWNER TO rolespcu1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc, role: rolespcu1 diskquota exceeded --- Test alter tablespace --- start_ignore -\! mkdir -p /tmp/rolespc2 --- end_ignore -DROP TABLESPACE IF EXISTS rolespc2; -NOTICE: tablespace "rolespc2" does not exist, skipping -CREATE TABLESPACE rolespc2 LOCATION '/tmp/rolespc2'; -ALTER TABLE b SET TABLESPACE rolespc2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO b SELECT generate_series(1,100); --- alter table b back to tablespace rolespc -ALTER TABLE b SET TABLESPACE rolespc; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc, role: rolespcu1 diskquota exceeded --- Test update quota config -SELECT diskquota.set_role_tablespace_quota('rolespcu1', 'rolespc', '10 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); --- expect insert success -INSERT INTO b SELECT generate_series(1,1000000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc, role: rolespcu1 diskquota exceeded --- Test delete quota config -SELECT diskquota.set_role_tablespace_quota('rolespcu1', 'rolespc', '-1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); --- superuser is blocked to set quota --- start_ignore -SELECT rolname from pg_roles where rolsuper=true; - rolname ---------- - zhrt -(1 row) - --- end_ignore -\gset -select diskquota.set_role_tablespace_quota(:'rolname', 'rolespc', '1mb'); -ERROR: Can not set disk quota for system owner: zhrt --- start_ignore -\! mkdir -p /tmp/rolespc3 --- end_ignore -DROP ROLE IF EXISTS "Rolespcu3"; -NOTICE: role "Rolespcu3" does not exist, skipping -CREATE ROLE "Rolespcu3" NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -DROP TABLESPACE IF EXISTS "Rolespc3"; -NOTICE: tablespace "Rolespc3" does not exist, skipping -CREATE TABLESPACE "Rolespc3" LOCATION '/tmp/rolespc3'; -SELECT diskquota.set_role_tablespace_quota('rolespcu1', '"Rolespc3"', '-1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.set_role_tablespace_quota('"Rolespcu3"', 'rolespc', '-1 mB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.set_role_tablespace_quota('"Rolespcu3"', '"Rolespc3"', '-1 Mb'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -DROP TABLE b, b2; -DROP ROLE rolespcu1, rolespcu2; -RESET search_path; -DROP SCHEMA rolespcrole; -DROP TABLESPACE rolespc; -DROP TABLESPACE rolespc2; -DROP TABLESPACE "Rolespc3"; diff --git a/tests/regress/expected7/test_tablespace_role_perseg.out b/tests/regress/expected7/test_tablespace_role_perseg.out deleted file mode 100644 index c3003032..00000000 --- a/tests/regress/expected7/test_tablespace_role_perseg.out +++ /dev/null @@ -1,235 +0,0 @@ --- Test role quota --- start_ignore -\! mkdir -p /tmp/rolespc_perseg --- end_ignore -DROP TABLESPACE IF EXISTS rolespc_perseg; -NOTICE: tablespace "rolespc_perseg" does not exist, skipping -CREATE TABLESPACE rolespc_perseg LOCATION '/tmp/rolespc_perseg'; -CREATE SCHEMA rolespc_persegrole; -SET search_path TO rolespc_persegrole; -DROP ROLE IF EXISTS rolespc_persegu1; -NOTICE: role "rolespc_persegu1" does not exist, skipping -DROP ROLE IF EXISTS rolespc_persegu2; -NOTICE: role "rolespc_persegu2" does not exist, skipping -CREATE ROLE rolespc_persegu1 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE ROLE rolespc_persegu2 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -CREATE TABLE b (t TEXT) TABLESPACE rolespc_perseg DISTRIBUTED BY (t); -ALTER TABLE b OWNER TO rolespc_persegu1; -SELECT diskquota.set_role_tablespace_quota('rolespc_persegu1', 'rolespc_perseg', '1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -INSERT INTO b SELECT generate_series(1,100); --- expect insert success -INSERT INTO b SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc_perseg, role: rolespc_persegu1 diskquota exceeded --- change tablespace role quota -SELECT diskquota.set_role_tablespace_quota('rolespc_persegu1', 'rolespc_perseg', '10 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); --- Test show_fast_schema_tablespace_quota_view -SELECT role_name, tablespace_name, quota_in_mb, rolsize_tablespace_in_bytes FROM diskquota.show_fast_role_tablespace_quota_view WHERE role_name = 'rolespc_persegu1' and tablespace_name = 'rolespc_perseg'; - role_name | tablespace_name | quota_in_mb | rolsize_tablespace_in_bytes -------------------+-----------------+-------------+----------------------------- - rolespc_persegu1 | rolespc_perseg | 10 | 4063232 -(1 row) - -SELECT diskquota.set_per_segment_quota('rolespc_perseg', '0.1'); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - ----- expect insert fail by tablespace schema perseg quota -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc_perseg, role: rolespc_persegu1 diskquota exceeded per segment quota --- Test alter owner -ALTER TABLE b OWNER TO rolespc_persegu2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO b SELECT generate_series(1,100); -ALTER TABLE b OWNER TO rolespc_persegu1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc_perseg, role: rolespc_persegu1 diskquota exceeded per segment quota --- Test alter tablespace --- start_ignore -\! mkdir -p /tmp/rolespc_perseg2 --- end_ignore -DROP TABLESPACE IF EXISTS rolespc_perseg2; -NOTICE: tablespace "rolespc_perseg2" does not exist, skipping -CREATE TABLESPACE rolespc_perseg2 LOCATION '/tmp/rolespc_perseg2'; -ALTER TABLE b SET TABLESPACE rolespc_perseg2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO b SELECT generate_series(1,100); --- alter table b back to tablespace rolespc_perseg -ALTER TABLE b SET TABLESPACE rolespc_perseg; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc_perseg, role: rolespc_persegu1 diskquota exceeded per segment quota --- Test update per segment ratio -SELECT diskquota.set_per_segment_quota('rolespc_perseg', 3.1); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT role_name, tablespace_name, quota_in_mb, rolsize_tablespace_in_bytes FROM diskquota.show_fast_role_tablespace_quota_view WHERE role_name = 'rolespc_persegu1' and tablespace_name = 'rolespc_perseg'; - role_name | tablespace_name | quota_in_mb | rolsize_tablespace_in_bytes -------------------+-----------------+-------------+----------------------------- - rolespc_persegu1 | rolespc_perseg | 10 | 4063232 -(1 row) - -SELECT diskquota.set_per_segment_quota('rolespc_perseg', 0.11); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc_perseg, role: rolespc_persegu1 diskquota exceeded per segment quota --- Test delete per segment ratio -SELECT diskquota.set_per_segment_quota('rolespc_perseg', -1); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); -SELECT diskquota.set_per_segment_quota('rolespc_perseg', 0.11); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO b SELECT generate_series(1,100); -ERROR: tablespace: rolespc_perseg, role: rolespc_persegu1 diskquota exceeded per segment quota --- Test delete quota config -SELECT diskquota.set_role_tablespace_quota('rolespc_persegu1', 'rolespc_perseg', '-1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO b SELECT generate_series(1,100); --- start_ignore -\! mkdir -p /tmp/rolespc_perseg3 --- end_ignore -DROP TABLESPACE IF EXISTS "Rolespc_perseg3"; -NOTICE: tablespace "Rolespc_perseg3" does not exist, skipping -CREATE TABLESPACE "Rolespc_perseg3" LOCATION '/tmp/rolespc_perseg3'; -CREATE ROLE "Rolespc_persegu3" NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -SELECT diskquota.set_role_tablespace_quota('"Rolespc_persegu3"', '"Rolespc_perseg3"', '-1 MB'); - set_role_tablespace_quota ---------------------------- - -(1 row) - -SELECT diskquota.set_per_segment_quota('"Rolespc_perseg3"', 0.11); - set_per_segment_quota ------------------------ - -(1 row) - -DROP table b; -DROP ROLE rolespc_persegu1, rolespc_persegu2, "Rolespc_persegu3"; -RESET search_path; -DROP SCHEMA rolespc_persegrole; -DROP TABLESPACE rolespc_perseg; -DROP TABLESPACE rolespc_perseg2; -DROP TABLESPACE "Rolespc_perseg3"; diff --git a/tests/regress/expected7/test_tablespace_schema.out b/tests/regress/expected7/test_tablespace_schema.out deleted file mode 100644 index a7e57c59..00000000 --- a/tests/regress/expected7/test_tablespace_schema.out +++ /dev/null @@ -1,147 +0,0 @@ --- Test schema --- start_ignore -\! mkdir -p /tmp/schemaspc --- end_ignore -CREATE SCHEMA spcs1; -DROP TABLESPACE IF EXISTS schemaspc; -NOTICE: tablespace "schemaspc" does not exist, skipping -CREATE TABLESPACE schemaspc LOCATION '/tmp/schemaspc'; -SET search_path TO spcs1; -CREATE TABLE a(i int) TABLESPACE schemaspc DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100); --- expect insert fail -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.set_schema_tablespace_quota('spcs1', 'schemaspc','1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: tablespace: schemaspc, schema: spcs1 diskquota exceeded -CREATE TABLE a2(i int) TABLESPACE schemaspc DISTRIBUTED BY (i); --- expect insert fail -INSERT INTO a2 SELECT generate_series(1,100); -ERROR: tablespace: schemaspc, schema: spcs1 diskquota exceeded --- Test alter table set schema -CREATE SCHEMA spcs2; -ALTER TABLE spcs1.a SET SCHEMA spcs2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO a2 SELECT generate_series(1,200); --- expect insert succeed -INSERT INTO spcs2.a SELECT generate_series(1,200); -ALTER TABLE spcs2.a SET SCHEMA spcs1; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,200); -ERROR: tablespace: schemaspc, schema: spcs1 diskquota exceeded -SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view WHERE schema_name = 'spcs1' and tablespace_name ='schemaspc'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes --------------+-----------------+-------------+----------------------------- - spcs1 | schemaspc | 1 | 4030464 -(1 row) - --- Test alter tablespace --- start_ignore -\! mkdir -p /tmp/schemaspc2 --- end_ignore -DROP TABLESPACE IF EXISTS schemaspc2; -NOTICE: tablespace "schemaspc2" does not exist, skipping -CREATE TABLESPACE schemaspc2 LOCATION '/tmp/schemaspc2'; -ALTER TABLE a SET TABLESPACE schemaspc2; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO a SELECT generate_series(1,200); -ALTER TABLE a SET TABLESPACE schemaspc; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,200); -ERROR: tablespace: schemaspc, schema: spcs1 diskquota exceeded --- Test update quota config -SELECT diskquota.set_schema_tablespace_quota('spcs1', 'schemaspc', '10 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO a SELECT generate_series(1,100); --- expect insert success -INSERT INTO a SELECT generate_series(1,1000000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: tablespace: schemaspc, schema: spcs1 diskquota exceeded --- Test delete quota config -SELECT diskquota.set_schema_tablespace_quota('spcs1', 'schemaspc', '-1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO a SELECT generate_series(1,100); --- start_ignore -\! mkdir -p /tmp/schemaspc3 --- end_ignore -DROP TABLESPACE IF EXISTS "Schemaspc3"; -NOTICE: tablespace "Schemaspc3" does not exist, skipping -CREATE TABLESPACE "Schemaspc3" LOCATION '/tmp/schemaspc3'; -CREATE SCHEMA "Spcs2"; -SELECT diskquota.set_schema_tablespace_quota('"Spcs2"', '"Schemaspc3"', '-1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -RESET search_path; -DROP TABLE spcs1.a2, spcs1.a; -DROP SCHEMA spcs1, spcs2; -DROP TABLESPACE schemaspc; -DROP TABLESPACE schemaspc2; -DROP TABLESPACE "Schemaspc3"; diff --git a/tests/regress/expected7/test_tablespace_schema_perseg.out b/tests/regress/expected7/test_tablespace_schema_perseg.out deleted file mode 100644 index c27f3e0e..00000000 --- a/tests/regress/expected7/test_tablespace_schema_perseg.out +++ /dev/null @@ -1,282 +0,0 @@ --- Test schema --- start_ignore -\! mkdir -p /tmp/schemaspc_perseg --- end_ignore --- Test tablespace quota perseg -CREATE SCHEMA spcs1_perseg; -DROP TABLESPACE IF EXISTS schemaspc_perseg; -NOTICE: tablespace "schemaspc_perseg" does not exist, skipping -CREATE TABLESPACE schemaspc_perseg LOCATION '/tmp/schemaspc_perseg'; -SELECT diskquota.set_schema_tablespace_quota('spcs1_perseg', 'schemaspc_perseg','1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SET search_path TO spcs1_perseg; -CREATE TABLE a(i int) TABLESPACE schemaspc_perseg DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100); --- expect insert success -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail by tablespace schema diskquota -INSERT INTO a SELECT generate_series(1,100); -ERROR: tablespace: schemaspc_perseg, schema: spcs1_perseg diskquota exceeded --- change tablespace schema quota -SELECT diskquota.set_schema_tablespace_quota('spcs1_perseg', 'schemaspc_perseg', '10 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO a SELECT generate_series(1,100); -SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view WHERE schema_name = 'spcs1_perseg' and tablespace_name ='schemaspc_perseg'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes ---------------+------------------+-------------+----------------------------- - spcs1_perseg | schemaspc_perseg | 10 | 3932160 -(1 row) - -SELECT diskquota.set_per_segment_quota('schemaspc_perseg', 0.1); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - ----- expect insert fail by tablespace schema perseg quota -INSERT INTO a SELECT generate_series(1,100); -ERROR: tablespace: schemaspc_perseg, schema: spcs1_perseg diskquota exceeded per segment quota --- Test alter table set schema -CREATE SCHEMA spcs2_perseg; -ALTER TABLE spcs1_perseg.a SET SCHEMA spcs2_perseg; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO spcs2_perseg.a SELECT generate_series(1,200); -ALTER TABLE spcs2_perseg.a SET SCHEMA spcs1_perseg; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,200); -ERROR: tablespace: schemaspc_perseg, schema: spcs1_perseg diskquota exceeded per segment quota -SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view WHERE schema_name = 'spcs1_perseg' and tablespace_name ='schemaspc_perseg'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes ---------------+------------------+-------------+----------------------------- - spcs1_perseg | schemaspc_perseg | 10 | 3932160 -(1 row) - --- Test alter tablespace --- start_ignore -\! mkdir -p /tmp/schemaspc_perseg2 --- end_ignore -DROP TABLESPACE IF EXISTS "Schemaspc_perseg2"; -NOTICE: tablespace "Schemaspc_perseg2" does not exist, skipping -CREATE TABLESPACE "Schemaspc_perseg2" LOCATION '/tmp/schemaspc_perseg2'; -ALTER TABLE a SET TABLESPACE "Schemaspc_perseg2"; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO a SELECT generate_series(1,200); -ALTER TABLE a SET TABLESPACE schemaspc_perseg; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,200); -ERROR: tablespace: schemaspc_perseg, schema: spcs1_perseg diskquota exceeded per segment quota --- Test update per segment ratio -SELECT diskquota.set_per_segment_quota('schemaspc_perseg', 3.1); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO a SELECT generate_series(1,100); -SELECT diskquota.set_per_segment_quota('schemaspc_perseg', 0.123); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - ----- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: tablespace: schemaspc_perseg, schema: spcs1_perseg diskquota exceeded per segment quota --- Test delete per segment ratio -SELECT diskquota.set_per_segment_quota('schemaspc_perseg', -1); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO a SELECT generate_series(1,100); -SELECT diskquota.set_per_segment_quota('schemaspc_perseg', 0.123); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - ----- expect insert fail -INSERT INTO a SELECT generate_series(1,100); -ERROR: tablespace: schemaspc_perseg, schema: spcs1_perseg diskquota exceeded per segment quota --- Test delete tablespace schema quota -SELECT diskquota.set_per_segment_quota('schemaspc_perseg', 2); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT diskquota.set_schema_tablespace_quota('spcs1_perseg', 'schemaspc_perseg','-1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert success -INSERT INTO a SELECT generate_series(1,100); -SELECT schema_name, tablespace_name, quota_in_mb, nspsize_tablespace_in_bytes FROM diskquota.show_fast_schema_tablespace_quota_view WHERE schema_name = 'spcs1_perseg' and tablespace_name ='schemaspc_perseg'; - schema_name | tablespace_name | quota_in_mb | nspsize_tablespace_in_bytes --------------+-----------------+-------------+----------------------------- -(0 rows) - --- test config per segment quota -SELECT diskquota.set_per_segment_quota('"Schemaspc_perseg2"','1'); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT distinct(segratio) from diskquota.quota_config, pg_tablespace where targetoid = oid and spcname = 'Schemaspc_perseg2'; - segratio ----------- - 1 -(1 row) - -SELECT diskquota.set_schema_tablespace_quota('spcs2_perseg', '"Schemaspc_perseg2"','1 MB'); - set_schema_tablespace_quota ------------------------------ - -(1 row) - -SELECT distinct(segratio) FROM diskquota.quota_config, pg_namespace, diskquota.target - WHERE diskquota.quota_config.targetoid = diskquota.target.rowId AND - diskquota.target.primaryOid = pg_namespace.oid AND nspname = 'spcs2_perseg'; - segratio ----------- - 1 -(1 row) - -SELECT diskquota.set_per_segment_quota('"Schemaspc_perseg2"','-2'); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT distinct(segratio) from diskquota.quota_config, pg_tablespace where targetoid = oid and spcname = 'Schemaspc_perseg2'; - segratio ----------- -(0 rows) - -SELECT distinct(segratio) FROM diskquota.quota_config, pg_namespace, diskquota.target - WHERE diskquota.quota_config.targetoid = diskquota.target.rowId AND - diskquota.target.primaryOid = pg_namespace.oid AND nspname = 'spcs2_perseg'; - segratio ----------- - 0 -(1 row) - -SELECT diskquota.set_per_segment_quota('"Schemaspc_perseg2"','3'); - set_per_segment_quota ------------------------ - -(1 row) - -SELECT distinct(segratio) from diskquota.quota_config, pg_tablespace where targetoid = oid and spcname = 'Schemaspc_perseg2'; - segratio ----------- - 3 -(1 row) - -SELECT distinct(segratio) FROM diskquota.quota_config, pg_namespace, diskquota.target - WHERE diskquota.quota_config.targetoid = diskquota.target.rowId AND - diskquota.target.primaryOid = pg_namespace.oid AND nspname = 'spcs2_perseg'; - segratio ----------- - 3 -(1 row) - -SELECT tablespace_name, per_seg_quota_ratio FROM diskquota.show_segment_ratio_quota_view where tablespace_name in ('Schemaspc_perseg2', 'schemaspc_perseg'); - tablespace_name | per_seg_quota_ratio --------------------+--------------------- - schemaspc_perseg | 2 - Schemaspc_perseg2 | 3 -(2 rows) - -RESET search_path; -DROP TABLE spcs1_perseg.a; -DROP SCHEMA spcs1_perseg; -DROP TABLESPACE schemaspc_perseg; -DROP TABLESPACE "Schemaspc_perseg2"; diff --git a/tests/regress/expected7/test_temp_role.out b/tests/regress/expected7/test_temp_role.out deleted file mode 100644 index 44933257..00000000 --- a/tests/regress/expected7/test_temp_role.out +++ /dev/null @@ -1,40 +0,0 @@ --- Test temp table restrained by role id -CREATE SCHEMA strole; -CREATE ROLE u3temp NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" -SET search_path TO strole; -SELECT diskquota.set_role_quota('u3temp', '1MB'); - set_role_quota ----------------- - -(1 row) - -CREATE TABLE a(i int) DISTRIBUTED BY (i); -ALTER TABLE a OWNER TO u3temp; -CREATE TEMP TABLE ta(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. -ALTER TABLE ta OWNER TO u3temp; --- expected failed: fill temp table -INSERT INTO ta SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expected failed: -INSERT INTO a SELECT generate_series(1,100); -ERROR: role's disk space quota exceeded with name: u3temp -DROP TABLE ta; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -INSERT INTO a SELECT generate_series(1,100); -DROP TABLE a; -DROP ROLE u3temp; -RESET search_path; -DROP SCHEMA strole; diff --git a/tests/regress/expected7/test_toast.out b/tests/regress/expected7/test_toast.out deleted file mode 100644 index df0b0c15..00000000 --- a/tests/regress/expected7/test_toast.out +++ /dev/null @@ -1,31 +0,0 @@ --- Test toast -CREATE SCHEMA s5; -SELECT diskquota.set_schema_quota('s5', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO s5; -CREATE TABLE a5 (t text) DISTRIBUTED BY (t); -INSERT INTO a5 -SELECT (SELECT - string_agg(chr(floor(random() * 26)::int + 65), '') - FROM generate_series(1,10000)) -FROM generate_series(1,10000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert toast fail -INSERT INTO a5 -SELECT (SELECT - string_agg(chr(floor(random() * 26)::int + 65), '') - FROM generate_series(1,1000)) -FROM generate_series(1,1000); -ERROR: schema's disk space quota exceeded with name: s5 -DROP TABLE a5; -RESET search_path; -DROP SCHEMA s5; diff --git a/tests/regress/expected7/test_truncate.out b/tests/regress/expected7/test_truncate.out deleted file mode 100644 index a9fd1239..00000000 --- a/tests/regress/expected7/test_truncate.out +++ /dev/null @@ -1,36 +0,0 @@ --- Test truncate -CREATE SCHEMA s7; -SELECT diskquota.set_schema_quota('s7', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO s7; -CREATE TABLE a (i int) DISTRIBUTED BY (i); -CREATE TABLE b (i int) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,30); -ERROR: schema's disk space quota exceeded with name: s7 -INSERT INTO b SELECT generate_series(1,30); -ERROR: schema's disk space quota exceeded with name: s7 -TRUNCATE TABLE a; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert succeed -INSERT INTO a SELECT generate_series(1,30); -INSERT INTO b SELECT generate_series(1,30); -DROP TABLE a, b; -RESET search_path; -DROP SCHEMA s7; diff --git a/tests/regress/expected7/test_update.out b/tests/regress/expected7/test_update.out deleted file mode 100644 index 5ddb9d8c..00000000 --- a/tests/regress/expected7/test_update.out +++ /dev/null @@ -1,23 +0,0 @@ --- Test Update -CREATE SCHEMA s4; -SELECT diskquota.set_schema_quota('s4', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO s4; -CREATE TABLE a(i int) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect update fail. -UPDATE a SET i = 100; -ERROR: schema's disk space quota exceeded with name: s4 -DROP TABLE a; -RESET search_path; -DROP SCHEMA s4; diff --git a/tests/regress/expected7/test_update_db_cache.out b/tests/regress/expected7/test_update_db_cache.out deleted file mode 100644 index 785c8bff..00000000 --- a/tests/regress/expected7/test_update_db_cache.out +++ /dev/null @@ -1,64 +0,0 @@ ---start_ignore -CREATE DATABASE test_db_cache; ---end_ignore -\c test_db_cache -CREATE EXTENSION diskquota; -CREATE EXTENSION diskquota_test; --- Wait until the db cache gets updated -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -CREATE TABLE t(i) AS SELECT generate_series(1, 100000) -DISTRIBUTED BY (i); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid -FROM diskquota.table_size -WHERE tableid = 't'::regclass -ORDER BY segid; - tableid | size | segid ----------+---------+------- - t | 3637248 | -1 - t | 1212416 | 0 - t | 1212416 | 1 - t | 1212416 | 2 -(4 rows) - -DROP EXTENSION diskquota; --- Create table without extension -CREATE TABLE t_no_extension(i) AS SELECT generate_series(1, 100000) -DISTRIBUTED BY (i); -CREATE EXTENSION diskquota; -WARNING: [diskquota] diskquota is not ready because current database is not empty -HINT: please run 'SELECT diskquota.init_table_size_table();' to initialize diskquota -SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY'');'); - wait ------- - t -(1 row) - --- Should find nothing since t_no_extension is not recorded. -SELECT diskquota.diskquota_fetch_table_stat(0, ARRAY[]::oid[]) -FROM gp_dist_random('gp_id'); - diskquota_fetch_table_stat ----------------------------- -(0 rows) - -DROP TABLE t; -DROP TABLE t_no_extension; -SELECT diskquota.pause(); - pause -------- - -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE test_db_cache; diff --git a/tests/regress/expected7/test_vacuum.out b/tests/regress/expected7/test_vacuum.out deleted file mode 100644 index b032274e..00000000 --- a/tests/regress/expected7/test_vacuum.out +++ /dev/null @@ -1,57 +0,0 @@ --- Test vacuum full -CREATE SCHEMA s6; -SELECT diskquota.set_schema_quota('s6', '1 MB'); - set_schema_quota ------------------- - -(1 row) - -SET search_path TO s6; -CREATE TABLE a (i int) DISTRIBUTED BY (i); -CREATE TABLE b (i int) DISTRIBUTED BY (i); -INSERT INTO a SELECT generate_series(1,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - --- expect insert fail -INSERT INTO a SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: s6 --- expect insert fail -INSERT INTO b SELECT generate_series(1,10); -ERROR: schema's disk space quota exceeded with name: s6 -DELETE FROM a WHERE i > 10; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -VACUUM FULL a; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid from diskquota.table_size WHERE tableid::regclass::name NOT LIKE '%.%' ORDER BY size, segid DESC; - tableid | size | segid ----------+-------+------- - b | 0 | 2 - b | 0 | 1 - b | 0 | 0 - b | 0 | -1 - a | 32768 | 2 - a | 32768 | 1 - a | 32768 | 0 - a | 98304 | -1 -(8 rows) - --- expect insert succeed -INSERT INTO a SELECT generate_series(1,10); -INSERT INTO b SELECT generate_series(1,10); -DROP TABLE a, b; -RESET search_path; -DROP SCHEMA s6; diff --git a/tests/regress/expected7/test_worker_not_ready.out b/tests/regress/expected7/test_worker_not_ready.out deleted file mode 100644 index 0424cb65..00000000 --- a/tests/regress/expected7/test_worker_not_ready.out +++ /dev/null @@ -1,26 +0,0 @@ -CREATE DATABASE db_not_ready; -\c db_not_ready; -CREATE TABLE t (i int) DISTRIBUTED BY (i); -CREATE EXTENSION diskquota; -WARNING: [diskquota] diskquota is not ready because current database is not empty -HINT: please run 'SELECT diskquota.init_table_size_table();' to initialize diskquota -CREATE EXTENSION diskquota_test; -SELECT diskquota.set_role_quota(CURRENT_ROLE, '1 MB'); -ERROR: Can not set disk quota for system owner: zhrt -SELECT diskquota.pause(); - pause -------- - -(1 row) - --- diskquota.wait_for_worker_new_epoch() cannot be used here because --- diskquota.state is not clean. -SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY'');'); - wait ------- - t -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE db_not_ready; diff --git a/tests/regress/expected7/test_worker_schedule.out b/tests/regress/expected7/test_worker_schedule.out deleted file mode 100644 index ad018a37..00000000 --- a/tests/regress/expected7/test_worker_schedule.out +++ /dev/null @@ -1,633 +0,0 @@ --- start_ignore -\c -DROP DATABASE IF EXISTS t1; -NOTICE: database "t1" does not exist, skipping -DROP DATABASE IF EXISTS t2; -NOTICE: database "t2" does not exist, skipping -DROP DATABASE IF EXISTS t3; -NOTICE: database "t3" does not exist, skipping -DROP DATABASE IF EXISTS t4; -NOTICE: database "t4" does not exist, skipping -DROP DATABASE IF EXISTS t5; -NOTICE: database "t5" does not exist, skipping -DROP DATABASE IF EXISTS t6; -NOTICE: database "t6" does not exist, skipping -DROP DATABASE IF EXISTS t7; -NOTICE: database "t7" does not exist, skipping -DROP DATABASE IF EXISTS t8; -NOTICE: database "t8" does not exist, skipping -DROP DATABASE IF EXISTS t9; -NOTICE: database "t9" does not exist, skipping -DROP DATABASE IF EXISTS t10; -NOTICE: database "t10" does not exist, skipping -DROP DATABASE IF EXISTS t11; -NOTICE: database "t11" does not exist, skipping -DROP DATABASE IF EXISTS t12; -NOTICE: database "t12" does not exist, skipping -CREATE DATABASE t1; -CREATE DATABASE t2; -CREATE DATABASE t3; -CREATE DATABASE t4; -CREATE DATABASE t5; -CREATE DATABASE t6; -CREATE DATABASE t7; -CREATE DATABASE t8; -CREATE DATABASE t9; -CREATE DATABASE t10; -CREATE DATABASE t11; -CREATE DATABASE t12; ---end_ignore -\c t1 -CREATE EXTENSION diskquota; -CREATE TABLE f1(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f1 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f1'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f1 | 98304 | -1 -(1 row) - ---start_ignore -\! gpconfig -c diskquota.max_workers -v 1; -20230117:13:00:12:1977590 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.max_workers -v 1' -\! gpstop -arf; -20230117:13:00:12:1978021 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:13:00:12:1978021 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:13:00:12:1978021 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:13:00:12:1978021 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:13:00:13:1978021 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:13:00:14:1978021 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore -\c -SHOW diskquota.max_workers; - diskquota.max_workers ------------------------ - 1 -(1 row) - -\c t2 -CREATE EXTENSION diskquota; -CREATE TABLE f2(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f2 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f2'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f2 | 98304 | -1 -(1 row) - -\c t3 -CREATE EXTENSION diskquota; -CREATE TABLE f3(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f3 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f3'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f3 | 98304 | -1 -(1 row) - ---start_ignore -\! gpconfig -c diskquota.max_workers -v 11; -20230117:13:02:24:1981283 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.max_workers -v 11' -\! gpstop -arf; -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:02:24:1981861 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:13:02:25:1981861 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore -\c -SHOW diskquota.max_workers; - diskquota.max_workers ------------------------ - 11 -(1 row) - -\c t4 -CREATE EXTENSION diskquota; -CREATE TABLE f4(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f4 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f4'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f4 | 98304 | -1 -(1 row) - -\c t5 -CREATE EXTENSION diskquota; -CREATE TABLE f5(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f5 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f5'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f5 | 98304 | -1 -(1 row) - -\c t6 -CREATE EXTENSION diskquota; -CREATE TABLE f6(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f6 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f6'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f6 | 98304 | -1 -(1 row) - -\c t7 -CREATE EXTENSION diskquota; -CREATE TABLE f7(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f7 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f7'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f7 | 98304 | -1 -(1 row) - -\c t8 -CREATE EXTENSION diskquota; -CREATE TABLE f8(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f8 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f8'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f8 | 98304 | -1 -(1 row) - -\c t9 -CREATE EXTENSION diskquota; -CREATE TABLE f9(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f9 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f9'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f9 | 98304 | -1 -(1 row) - -\c t10 -CREATE EXTENSION diskquota; -CREATE TABLE f10(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f10 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f10'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f10 | 98304 | -1 -(1 row) - -\c t11 -CREATE EXTENSION diskquota; -CREATE TABLE f11(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f11 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f11'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f11 | 98304 | -1 -(1 row) - -\c t1 -INSERT into f1 SELECT generate_series(0,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f1'::regclass and segid = -1; - tableid | size | segid ----------+---------+------- - f1 | 3997696 | -1 -(1 row) - -\c t7 -INSERT into f7 SELECT generate_series(0,100000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f7'::regclass and segid = -1; - tableid | size | segid ----------+---------+------- - f7 | 3997696 | -1 -(1 row) - -\c t1 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -DROP TABLE f1; -CREATE EXTENSION diskquota; -CREATE TABLE f1(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f1 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f1'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f1 | 98304 | -1 -(1 row) - -\c t2 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -DROP TABLE f2; -CREATE EXTENSION diskquota; -CREATE TABLE f2(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f2 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f2'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f2 | 98304 | -1 -(1 row) - -\c t3 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t4 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t5 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t6 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t7 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t8 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t9 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t10 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t11 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t12 -CREATE EXTENSION diskquota; -CREATE TABLE f12(a int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' 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. -INSERT into f12 SELECT generate_series(0,1000); -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -SELECT tableid::regclass, size, segid FROM diskquota.table_size WHERE tableid = 'f12'::regclass and segid = -1; - tableid | size | segid ----------+-------+------- - f12 | 98304 | -1 -(1 row) - -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t1 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c t2 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; ---start_ignore -\c contrib_regression -DROP DATABASE t1; -DROP DATABASE t2; -DROP DATABASE t3; -DROP DATABASE t4; -DROP DATABASE t5; -DROP DATABASE t6; -DROP DATABASE t7; -DROP DATABASE t8; -DROP DATABASE t9; -DROP DATABASE t10; -DROP DATABASE t11; -DROP DATABASE t12; -\! gpconfig -r diskquota.worker_timeout; -20230117:13:04:52:2001815 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-r diskquota.worker_timeout' -\! gpconfig -r diskquota.max_workers; -20230117:13:04:53:2002403 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-r diskquota.max_workers' -\! gpstop -arf; -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:04:53:2003022 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:13:04:54:2003022 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:13:04:55:2003022 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore diff --git a/tests/regress/expected7/test_worker_schedule_exception.out b/tests/regress/expected7/test_worker_schedule_exception.out deleted file mode 100644 index aeb8e5d8..00000000 --- a/tests/regress/expected7/test_worker_schedule_exception.out +++ /dev/null @@ -1,113 +0,0 @@ --- start_ignore -\! gpconfig -c diskquota.max_workers -v 10; -20230117:13:07:03:2006049 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.max_workers -v 10' -\! gpconfig -c diskquota.naptime -v 4; -20230117:13:07:04:2006587 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-c diskquota.naptime -v 4' -\! gpstop -arf; -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:07:04:2007250 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:13:07:05:2007250 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:13:07:06:2007250 gpstop:zhrt:zhrt-[INFO]:-Restarting System... -\c -DROP DATABASE IF EXISTS t1; -NOTICE: database "t1" does not exist, skipping -DROP DATABASE IF EXISTS t2; -NOTICE: database "t2" does not exist, skipping ---end_ignore -CREATE DATABASE t1; -CREATE DATABASE t2; -\c t1 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\! pgrep -f "[p]ostgres.*bgworker.*t1" | xargs kill; -\! sleep 0.5 ; ps -ef | grep postgres | grep "\[diskquota]" | grep -v grep | wc -l -2 --- start_ignore -\! ps -ef | grep postgres | grep "\[diskquota]" | grep -v grep -zhrt 2009311 2009263 10 13:09 ? 00:00:00 postgres: 7000, [diskquota] - launcher -zhrt 2009361 2009263 1 13:09 ? 00:00:00 postgres: 7000, bgworker: [diskquota] contrib_regression con8 cmd1 ---end_ignore -\c contrib_regression -DROP DATABASE t1; -\c t2 -CREATE EXTENSION diskquota; -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -\c t2 -SELECT diskquota.pause(); - pause -------- - -(1 row) - -SELECT diskquota.wait_for_worker_new_epoch(); - wait_for_worker_new_epoch ---------------------------- - t -(1 row) - -DROP EXTENSION diskquota; -\c contrib_regression -DROP DATABASE t2; ---start_ignore -\! gpconfig -r diskquota.naptime; -20230117:13:09:27:2009995 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-r diskquota.naptime' -\! gpconfig -r diskquota.max_workers; -20230117:13:09:27:2010164 gpconfig:zhrt:zhrt-[INFO]:-completed successfully with parameters '-r diskquota.max_workers' -\! gpstop -arf; -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Starting gpstop with args: -arf -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Gathering information and validating the environment... -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Obtaining Greenplum Coordinator catalog information -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Obtaining Segment details from coordinator... -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 7.0.0-alpha.0+dev.16171.g005ee83c46 build dev' -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Commencing Coordinator instance shutdown with mode='fast' -20230117:13:09:27:2010416 gpstop:zhrt:zhrt-[INFO]:-Coordinator segment instance directory=/home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-Attempting forceful termination of any leftover coordinator process -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-Terminating processes for segment /home/zhrt/workspace/gpdb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-Stopping coordinator standby host zhrt mode=fast -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown standby process on zhrt -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-Targeting dbid [2, 5, 3, 6, 4, 7] for shutdown -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel primary segment instance shutdown, please wait... -20230117:13:09:28:2010416 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-Commencing parallel mirror segment instance shutdown, please wait... -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-0.00% of jobs completed -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-100.00% of jobs completed -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:- Segments stopped successfully = 6 -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:- Segments with errors during stop = 0 -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:----------------------------------------------------- -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-Successfully shutdown 6 of 6 segment instances -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-Database successfully shutdown with no errors reported -20230117:13:09:29:2010416 gpstop:zhrt:zhrt-[INFO]:-Restarting System... ---end_ignore From ddeb628c0f231e8920cdb0e019c0a102b0a5ea0b Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Thu, 16 Feb 2023 13:09:41 +0800 Subject: [PATCH 09/31] Fix update test failures caused by segid diff (#305) Due the GPDB change b80e969844, upgrade_test failed because the segid in the view dump is surrounded by quotes. Expected failure diff: -WHERE (table_size.segid = (-1)))) AS dbsize; +WHERE (table_size.segid = '-1'::integer))) AS dbsize; --- upgrade_test/expected/2.0_catalog.out | 10 +++++----- upgrade_test/expected/2.1_catalog.out | 10 +++++----- upgrade_test/expected/2.2_catalog.out | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/upgrade_test/expected/2.0_catalog.out b/upgrade_test/expected/2.0_catalog.out index 7d7aa740..73b05013 100644 --- a/upgrade_test/expected/2.0_catalog.out +++ b/upgrade_test/expected/2.0_catalog.out @@ -160,13 +160,13 @@ ORDER by | | FROM pg_class + | | WHERE (pg_class.oid <= (16384)::oid)) + ( SELECT sum(table_size.size) AS sum + | | FROM diskquota.table_size + - | | WHERE (table_size.segid = (-1)))) AS dbsize; + | | WHERE (table_size.segid = '-1'::integer))) AS dbsize; diskquota | show_fast_role_quota_view | WITH quota_usage AS ( + | | SELECT pg_class.relowner, + | | sum(table_size.size) AS total_size + | | FROM diskquota.table_size, + | | pg_class + - | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY pg_class.relowner + | | ) + | | SELECT pg_roles.rolname AS role_name, + @@ -191,7 +191,7 @@ ORDER by | | FROM diskquota.table_size, + | | pg_class, + | | default_tablespace + - | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY pg_class.relowner, pg_class.reltablespace, default_tablespace.dattablespace + | | ), full_quota_config AS ( + | | SELECT target.primaryoid, + @@ -216,7 +216,7 @@ ORDER by | | sum(table_size.size) AS total_size + | | FROM diskquota.table_size, + | | pg_class + - | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY pg_class.relnamespace + | | ) + | | SELECT pg_namespace.nspname AS schema_name, + @@ -241,7 +241,7 @@ ORDER by | | FROM diskquota.table_size, + | | pg_class, + | | default_tablespace + - | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = pg_class.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY pg_class.relnamespace, pg_class.reltablespace, default_tablespace.dattablespace + | | ), full_quota_config AS ( + | | SELECT target.primaryoid, + diff --git a/upgrade_test/expected/2.1_catalog.out b/upgrade_test/expected/2.1_catalog.out index 7582b33a..b22cec87 100644 --- a/upgrade_test/expected/2.1_catalog.out +++ b/upgrade_test/expected/2.1_catalog.out @@ -191,13 +191,13 @@ ORDER by | | FROM pg_class + | | WHERE (pg_class.oid <= (16384)::oid)) + ( SELECT sum(table_size.size) AS sum + | | FROM diskquota.table_size + - | | WHERE (table_size.segid = (-1)))) AS dbsize; + | | WHERE (table_size.segid = '-1'::integer))) AS dbsize; diskquota | show_fast_role_quota_view | WITH quota_usage AS ( + | | SELECT show_all_relation_view.relowner, + | | sum(table_size.size) AS total_size + | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relowner + | | ) + | | SELECT pg_roles.rolname AS role_name, + @@ -222,7 +222,7 @@ ORDER by | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view, + | | default_tablespace + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relowner, show_all_relation_view.reltablespace, default_tablespace.dattablespace + | | ), full_quota_config AS ( + | | SELECT target.primaryoid, + @@ -247,7 +247,7 @@ ORDER by | | sum(table_size.size) AS total_size + | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relnamespace + | | ) + | | SELECT pg_namespace.nspname AS schema_name, + @@ -272,7 +272,7 @@ ORDER by | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view, + | | default_tablespace + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relnamespace, show_all_relation_view.reltablespace, default_tablespace.dattablespace + | | ), full_quota_config AS ( + | | SELECT target.primaryoid, + diff --git a/upgrade_test/expected/2.2_catalog.out b/upgrade_test/expected/2.2_catalog.out index 287a353e..5654d0fb 100644 --- a/upgrade_test/expected/2.2_catalog.out +++ b/upgrade_test/expected/2.2_catalog.out @@ -198,13 +198,13 @@ ORDER by | | FROM pg_class + | | WHERE (pg_class.oid <= (16384)::oid)) + ( SELECT sum(table_size.size) AS sum + | | FROM diskquota.table_size + - | | WHERE (table_size.segid = (-1)))) AS dbsize; + | | WHERE (table_size.segid = '-1'::integer))) AS dbsize; diskquota | show_fast_role_quota_view | WITH quota_usage AS ( + | | SELECT show_all_relation_view.relowner, + | | sum(table_size.size) AS total_size + | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relowner + | | ) + | | SELECT pg_roles.rolname AS role_name, + @@ -229,7 +229,7 @@ ORDER by | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view, + | | default_tablespace + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relowner, show_all_relation_view.reltablespace, default_tablespace.dattablespace + | | ), full_quota_config AS ( + | | SELECT target.primaryoid, + @@ -254,7 +254,7 @@ ORDER by | | sum(table_size.size) AS total_size + | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relnamespace + | | ) + | | SELECT pg_namespace.nspname AS schema_name, + @@ -279,7 +279,7 @@ ORDER by | | FROM diskquota.table_size, + | | diskquota.show_all_relation_view, + | | default_tablespace + - | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = (-1))) + + | | WHERE ((table_size.tableid = show_all_relation_view.oid) AND (table_size.segid = '-1'::integer)) + | | GROUP BY show_all_relation_view.relnamespace, show_all_relation_view.reltablespace, default_tablespace.dattablespace + | | ), full_quota_config AS ( + | | SELECT target.primaryoid, + From b2b41a388f640dccf1310681f02dfad07c63f28b Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Thu, 16 Feb 2023 14:22:06 +0800 Subject: [PATCH 10/31] Replace relation_open/relation_close with RelationIdGetRelation/RelationClose. (#300) This PR replaces relation_open()/relation_close() with RelationIdGetRelation()/RelationClose() to avoid deadlock. We can only call relation_open() with AccessSharedLock in object_access_hook(OAT_POST_CREATE) in GPDB7, which may cause deadlock. While RelationIdGetRelation()/RelationClose() just locks pg_class instead of user-defined relation, so we use these functions to get the information of relations. --- diskquota.h | 2 +- diskquota_utility.c | 6 +++--- gp_activetable.c | 26 +++++++++++++------------- relation_cache.c | 29 ++++++++--------------------- 4 files changed, 25 insertions(+), 38 deletions(-) diff --git a/diskquota.h b/diskquota.h index a52037cf..0bd5ab30 100644 --- a/diskquota.h +++ b/diskquota.h @@ -265,7 +265,7 @@ extern int worker_spi_get_extension_version(int *major, int *minor); extern void truncateStringInfo(StringInfo str, int nchars); extern List *get_rel_oid_list(void); extern int64 calculate_relation_size_all_forks(RelFileNodeBackend *rnode, char relstorage, Oid relam); -extern Relation diskquota_relation_open(Oid relid, LOCKMODE mode); +extern Relation diskquota_relation_open(Oid relid); extern bool get_rel_name_namespace(Oid relid, Oid *nsOid, char *relname); extern List *diskquota_get_index_list(Oid relid); extern void diskquota_get_appendonly_aux_oid_list(Oid reloid, Oid *segrelid, Oid *blkdirrelid, Oid *visimaprelid); diff --git a/diskquota_utility.c b/diskquota_utility.c index da9bc080..f406809c 100644 --- a/diskquota_utility.c +++ b/diskquota_utility.c @@ -1441,7 +1441,7 @@ relation_size_local(PG_FUNCTION_ARGS) } Relation -diskquota_relation_open(Oid relid, LOCKMODE mode) +diskquota_relation_open(Oid relid) { Relation rel; bool success_open = false; @@ -1449,8 +1449,8 @@ diskquota_relation_open(Oid relid, LOCKMODE mode) PG_TRY(); { - rel = relation_open(relid, mode); - success_open = true; + rel = RelationIdGetRelation(relid); + if (rel) success_open = true; } PG_CATCH(); { diff --git a/gp_activetable.c b/gp_activetable.c index 4cf2144f..1b2d6842 100644 --- a/gp_activetable.c +++ b/gp_activetable.c @@ -246,6 +246,7 @@ report_relation_cache_helper(Oid relid) { bool found; Relation rel; + char relkind; /* We do not collect the active table in mirror segments */ if (IsRoleMirror()) @@ -265,20 +266,19 @@ report_relation_cache_helper(Oid relid) { return; } -#if GP_VERSION_NUM < 70000 - rel = diskquota_relation_open(relid, NoLock); -#else - rel = diskquota_relation_open(relid, AccessShareLock); -#endif /* GP_VERSION_NUM */ - if (rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE && rel->rd_rel->relkind != RELKIND_COMPOSITE_TYPE && - rel->rd_rel->relkind != RELKIND_VIEW) - update_relation_cache(relid); -#if GP_VERSION_NUM < 70000 - relation_close(rel, NoLock); -#else - relation_close(rel, AccessShareLock); -#endif /* GP_VERSION_NUM */ + rel = diskquota_relation_open(relid); + if (rel == NULL) + { + return; + } + + relkind = rel->rd_rel->relkind; + + RelationClose(rel); + + if (relkind != RELKIND_FOREIGN_TABLE && relkind != RELKIND_COMPOSITE_TYPE && relkind != RELKIND_VIEW) + update_relation_cache(relid); } /* diff --git a/relation_cache.c b/relation_cache.c index 352852e9..647779de 100644 --- a/relation_cache.c +++ b/relation_cache.c @@ -136,11 +136,7 @@ static void update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, DiskQuotaRelidCacheEntry *relid_entry) { Relation rel; -#if GP_VERSION_NUM < 70000 - rel = diskquota_relation_open(relid, NoLock); -#else - rel = diskquota_relation_open(relid, AccessShareLock); -#endif /* GP_VERSION_NUM */ + rel = diskquota_relation_open(relid); if (rel == NULL) { @@ -166,11 +162,7 @@ update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, Di relation_entry->primary_table_relid = relid; -#if GP_VERSION_NUM < 70000 - relation_close(rel, NoLock); -#else - relation_close(rel, AccessShareLock); -#endif /* GP_VERSION_NUM */ + RelationClose(rel); } void @@ -228,22 +220,16 @@ parse_primary_table_oid(Oid relid, bool on_bgworker) } else { -#if GP_VERSION_NUM < 70000 - rel = diskquota_relation_open(relid, NoLock); -#else - rel = diskquota_relation_open(relid, AccessShareLock); -#endif /* GP_VERSION_NUM */ + rel = diskquota_relation_open(relid); + if (rel == NULL) { return InvalidOid; } namespace = rel->rd_rel->relnamespace; memcpy(relname, rel->rd_rel->relname.data, NAMEDATALEN); -#if GP_VERSION_NUM < 70000 - relation_close(rel, NoLock); -#else - relation_close(rel, AccessShareLock); -#endif /* GP_VERSION_NUM */ + + RelationClose(rel); } parsed_oid = diskquota_parse_primary_table_oid(namespace, relname); @@ -331,7 +317,8 @@ show_relation_cache(PG_FUNCTION_ARGS) { HASH_SEQ_STATUS iter; HTAB *relation_cache; - } * relation_cache_ctx; + }; + struct RelationCacheCtx *relation_cache_ctx; if (SRF_IS_FIRSTCALL()) { From d86ead2afdcc4a1f0bdc5a972cfd3ee691c9a282 Mon Sep 17 00:00:00 2001 From: Xiaoran Wang Date: Mon, 20 Feb 2023 17:27:37 +0800 Subject: [PATCH 11/31] Fix flaky test of test_rejectmap_mul_db (#301) Add back the pause in the test, to avoid the changes of active table. --- tests/regress/expected/test_rejectmap_mul_db.out | 15 ++++++++++++++- tests/regress/sql/test_rejectmap_mul_db.sql | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/regress/expected/test_rejectmap_mul_db.out b/tests/regress/expected/test_rejectmap_mul_db.out index 78a10aad..8ac4193c 100644 --- a/tests/regress/expected/test_rejectmap_mul_db.out +++ b/tests/regress/expected/test_rejectmap_mul_db.out @@ -22,7 +22,14 @@ SELECT diskquota.wait_for_worker_new_epoch(); -- 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:8003 pid=43782) +ERROR: schema's disk space quota exceeded with name: 2200 (seg0 127.0.0.1:6002 pid=87165) +-- FIXME: Pause to avoid tjmu1's worker clear the active table. Since there are bugs, 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 @@ -54,6 +61,12 @@ SELECT diskquota.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 diff --git a/tests/regress/sql/test_rejectmap_mul_db.sql b/tests/regress/sql/test_rejectmap_mul_db.sql index 57fd16db..e59647f3 100644 --- a/tests/regress/sql/test_rejectmap_mul_db.sql +++ b/tests/regress/sql/test_rejectmap_mul_db.sql @@ -16,6 +16,8 @@ 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 +-- FIXME: Pause to avoid tjmu1's worker clear the active table. Since there are bugs, 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; @@ -27,6 +29,7 @@ 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 From e56694f80d11d6532df885560cb7f41779fd0be5 Mon Sep 17 00:00:00 2001 From: Xiaoran Wang Date: Tue, 21 Feb 2023 15:22:47 +0800 Subject: [PATCH 12/31] Fix test_primary_failure test case (#303) * subprocess.check_output of python3, needs encoding * Add @PLPYTHON_LANG_STR@ in the test_primary_failure.in.sql --- tests/CMakeLists.txt | 2 +- tests/regress/diskquota_schedule7 | 46 ------------------- .../regress/expected/test_primary_failure.out | 14 ++++-- ...ailure.sql => test_primary_failure.in.sql} | 16 +++++-- 4 files changed, 22 insertions(+), 56 deletions(-) delete mode 100644 tests/regress/diskquota_schedule7 rename tests/regress/sql/{test_primary_failure.sql => test_primary_failure.in.sql} (78%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 07abaf69..a2a3c4b7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,7 +26,7 @@ RegressTarget_Add(regress EXPECTED_DIR ${regress_expected_DIR} RESULTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/results DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data - SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/regress/diskquota_schedule${EXPECTED_DIR_SUFFIX} + SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/regress/diskquota_schedule EXCLUDE_FAULT_INJECT_TEST ${exclude_fault_injector} REGRESS_OPTS --load-extension=gp_inject_fault diff --git a/tests/regress/diskquota_schedule7 b/tests/regress/diskquota_schedule7 deleted file mode 100644 index 50dc40e3..00000000 --- a/tests/regress/diskquota_schedule7 +++ /dev/null @@ -1,46 +0,0 @@ -test: config -test: test_create_extension -test: test_readiness_logged -test: test_init_table_size_table -test: test_relation_size -test: test_relation_cache -test: test_uncommitted_table_size -test: test_pause_and_resume -test: test_pause_and_resume_multiple_db -test: test_drop_after_pause -test: test_show_status -test: test_update_db_cache -test: test_quota_view_no_table -# disable this test due to GPDB behavior change -# test: test_table_size -test: test_fast_disk_check -test: test_worker_not_ready -#test: test_insert_after_drop -test: test_role test_schema test_drop_table test_column test_copy test_update test_toast test_truncate test_reschema test_temp_role test_rename test_delete_quota test_mistake test_tablespace_role test_tablespace_schema test_tablespace_role_perseg test_tablespace_schema_perseg test_index test_recreate -test: test_ctas_no_preload_lib -test: test_ctas_before_set_quota -test: test_truncate -test: test_delete_quota -test: test_partition -test: test_vacuum -# plpython is not avilable in gpdb7, should change it to plpython3 -# test: test_primary_failure -test: test_extension -test: test_activetable_limit -test: test_many_active_tables -test: test_fetch_table_stat -test: test_appendonly -test: test_rejectmap -test: test_clean_rejectmap_after_drop -test: test_rejectmap_mul_db -test: test_ctas_pause -test: test_ctas_role -test: test_ctas_schema -test: test_ctas_tablespace_role -test: test_ctas_tablespace_schema -test: test_default_tablespace -test: test_tablespace_diff_schema -test: test_worker_schedule -test: test_worker_schedule_exception -test: test_drop_extension -test: reset_config diff --git a/tests/regress/expected/test_primary_failure.out b/tests/regress/expected/test_primary_failure.out index 99985501..5f5c18a2 100644 --- a/tests/regress/expected/test_primary_failure.out +++ b/tests/regress/expected/test_primary_failure.out @@ -21,15 +21,21 @@ returns text as $$ cmd = 'pg_ctl -l postmaster.log -D %s ' % datadir cmd = cmd + '-W -m %s %s' % (command_mode, command) + if 'plpython2u' == 'plpython2u': + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') + else: + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True, encoding='utf8').replace('.', '') - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') -$$ language plpythonu; +$$ language plpython2u; create or replace function pg_recoverseg(datadir text, command text) returns text as $$ import subprocess cmd = 'gprecoverseg -%s -d %s; exit 0; ' % (command, datadir) - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') -$$ language plpythonu; + if 'plpython2u' == 'plpython2u': + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') + else: + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True, encoding='utf8').replace('.', '') +$$ language plpython2u; CREATE TABLE a(i int) DISTRIBUTED BY (i); 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. diff --git a/tests/regress/sql/test_primary_failure.sql b/tests/regress/sql/test_primary_failure.in.sql similarity index 78% rename from tests/regress/sql/test_primary_failure.sql rename to tests/regress/sql/test_primary_failure.in.sql index 14556741..cbac6e4c 100644 --- a/tests/regress/sql/test_primary_failure.sql +++ b/tests/regress/sql/test_primary_failure.in.sql @@ -1,7 +1,7 @@ CREATE SCHEMA ftsr; SELECT diskquota.set_schema_quota('ftsr', '1 MB'); SET search_path TO ftsr; -create or replace language plpythonu; +create or replace language @PLPYTHON_LANG_STR@; -- -- pg_ctl: -- datadir: data directory of process to target with `pg_ctl` @@ -16,16 +16,22 @@ returns text as $$ cmd = 'pg_ctl -l postmaster.log -D %s ' % datadir cmd = cmd + '-W -m %s %s' % (command_mode, command) + if '@PLPYTHON_LANG_STR@' == 'plpython2u': + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') + else: + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True, encoding='utf8').replace('.', '') - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') -$$ language plpythonu; +$$ language @PLPYTHON_LANG_STR@; create or replace function pg_recoverseg(datadir text, command text) returns text as $$ import subprocess cmd = 'gprecoverseg -%s -d %s; exit 0; ' % (command, datadir) - return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') -$$ language plpythonu; + if '@PLPYTHON_LANG_STR@' == 'plpython2u': + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') + else: + return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True, encoding='utf8').replace('.', '') +$$ language @PLPYTHON_LANG_STR@; CREATE TABLE a(i int) DISTRIBUTED BY (i); INSERT INTO a SELECT generate_series(1,100); From 97f1f9b46b0941a86cffdb2120b900b55ce58928 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Wed, 22 Feb 2023 13:53:55 +0800 Subject: [PATCH 13/31] Move files to src and control dirs. (#307) - Move .c and .h files to src dir. - Move diskquota ddl file to control/ddl dir. - Move diskquota_test--1.0.sql file to control/test dir. --- CMakeLists.txt | 30 ++++--------------- .../ddl/diskquota--1.0--2.0.sql | 0 .../ddl/diskquota--1.0.sql | 0 .../ddl/diskquota--2.0--1.0.sql | 0 .../ddl/diskquota--2.0--2.1.sql | 0 .../ddl/diskquota--2.0.sql | 0 .../ddl/diskquota--2.1--2.0.sql | 0 .../ddl/diskquota--2.1--2.2.sql | 0 .../ddl/diskquota--2.1.sql | 0 .../ddl/diskquota--2.2--2.1.sql | 0 .../ddl/diskquota--2.2.sql | 0 .../ddl/diskquota.control | 0 .../test/diskquota_test--1.0.sql | 0 .../test/diskquota_test.control | 0 diskquota.c => src/diskquota.c | 0 diskquota.h => src/diskquota.h | 0 diskquota_enum.h => src/diskquota_enum.h | 0 .../diskquota_utility.c | 0 enforcement.c => src/enforcement.c | 0 gp_activetable.c => src/gp_activetable.c | 0 gp_activetable.h => src/gp_activetable.h | 0 monitored_db.c => src/monitored_db.c | 0 quotamodel.c => src/quotamodel.c | 0 relation_cache.c => src/relation_cache.c | 0 relation_cache.h => src/relation_cache.h | 0 tests/CMakeLists.txt | 4 +-- 26 files changed, 7 insertions(+), 27 deletions(-) rename diskquota--1.0--2.0.sql => control/ddl/diskquota--1.0--2.0.sql (100%) rename diskquota--1.0.sql => control/ddl/diskquota--1.0.sql (100%) rename diskquota--2.0--1.0.sql => control/ddl/diskquota--2.0--1.0.sql (100%) rename diskquota--2.0--2.1.sql => control/ddl/diskquota--2.0--2.1.sql (100%) rename diskquota--2.0.sql => control/ddl/diskquota--2.0.sql (100%) rename diskquota--2.1--2.0.sql => control/ddl/diskquota--2.1--2.0.sql (100%) rename diskquota--2.1--2.2.sql => control/ddl/diskquota--2.1--2.2.sql (100%) rename diskquota--2.1.sql => control/ddl/diskquota--2.1.sql (100%) rename diskquota--2.2--2.1.sql => control/ddl/diskquota--2.2--2.1.sql (100%) rename diskquota--2.2.sql => control/ddl/diskquota--2.2.sql (100%) rename diskquota.control => control/ddl/diskquota.control (100%) rename diskquota_test--1.0.sql => control/test/diskquota_test--1.0.sql (100%) rename diskquota_test.control => control/test/diskquota_test.control (100%) rename diskquota.c => src/diskquota.c (100%) rename diskquota.h => src/diskquota.h (100%) rename diskquota_enum.h => src/diskquota_enum.h (100%) rename diskquota_utility.c => src/diskquota_utility.c (100%) rename enforcement.c => src/enforcement.c (100%) rename gp_activetable.c => src/gp_activetable.c (100%) rename gp_activetable.h => src/gp_activetable.h (100%) rename monitored_db.c => src/monitored_db.c (100%) rename quotamodel.c => src/quotamodel.c (100%) rename relation_cache.c => src/relation_cache.c (100%) rename relation_cache.h => src/relation_cache.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62111646..a79be595 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,31 +64,11 @@ add_compile_definitions( DISKQUOTA_PATCH_VERSION=${DISKQUOTA_PATCH_VERSION} DISKQUOTA_BINARY_NAME="${DISKQUOTA_BINARY_NAME}") -list( - APPEND - diskquota_SRC - diskquota.c - diskquota_utility.c - enforcement.c - gp_activetable.c - quotamodel.c - relation_cache.c - monitored_db.c) - -list( - APPEND - diskquota_DDL - diskquota.control - diskquota--1.0.sql - diskquota--1.0--2.0.sql - diskquota--2.0.sql - diskquota--2.0--1.0.sql - diskquota--2.1.sql - diskquota--2.0--2.1.sql - diskquota--2.1--2.0.sql - diskquota--2.2.sql - diskquota--2.1--2.2.sql - diskquota--2.2--2.1.sql) +set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") +file(GLOB diskquota_SRC "${SRC_DIR}/*.c") + +set(DISKQUOTA_DDL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/control/ddl") +file(GLOB diskquota_DDL "${DISKQUOTA_DDL_DIR}/*") add_library(diskquota MODULE ${diskquota_SRC}) diff --git a/diskquota--1.0--2.0.sql b/control/ddl/diskquota--1.0--2.0.sql similarity index 100% rename from diskquota--1.0--2.0.sql rename to control/ddl/diskquota--1.0--2.0.sql diff --git a/diskquota--1.0.sql b/control/ddl/diskquota--1.0.sql similarity index 100% rename from diskquota--1.0.sql rename to control/ddl/diskquota--1.0.sql diff --git a/diskquota--2.0--1.0.sql b/control/ddl/diskquota--2.0--1.0.sql similarity index 100% rename from diskquota--2.0--1.0.sql rename to control/ddl/diskquota--2.0--1.0.sql diff --git a/diskquota--2.0--2.1.sql b/control/ddl/diskquota--2.0--2.1.sql similarity index 100% rename from diskquota--2.0--2.1.sql rename to control/ddl/diskquota--2.0--2.1.sql diff --git a/diskquota--2.0.sql b/control/ddl/diskquota--2.0.sql similarity index 100% rename from diskquota--2.0.sql rename to control/ddl/diskquota--2.0.sql diff --git a/diskquota--2.1--2.0.sql b/control/ddl/diskquota--2.1--2.0.sql similarity index 100% rename from diskquota--2.1--2.0.sql rename to control/ddl/diskquota--2.1--2.0.sql diff --git a/diskquota--2.1--2.2.sql b/control/ddl/diskquota--2.1--2.2.sql similarity index 100% rename from diskquota--2.1--2.2.sql rename to control/ddl/diskquota--2.1--2.2.sql diff --git a/diskquota--2.1.sql b/control/ddl/diskquota--2.1.sql similarity index 100% rename from diskquota--2.1.sql rename to control/ddl/diskquota--2.1.sql diff --git a/diskquota--2.2--2.1.sql b/control/ddl/diskquota--2.2--2.1.sql similarity index 100% rename from diskquota--2.2--2.1.sql rename to control/ddl/diskquota--2.2--2.1.sql diff --git a/diskquota--2.2.sql b/control/ddl/diskquota--2.2.sql similarity index 100% rename from diskquota--2.2.sql rename to control/ddl/diskquota--2.2.sql diff --git a/diskquota.control b/control/ddl/diskquota.control similarity index 100% rename from diskquota.control rename to control/ddl/diskquota.control diff --git a/diskquota_test--1.0.sql b/control/test/diskquota_test--1.0.sql similarity index 100% rename from diskquota_test--1.0.sql rename to control/test/diskquota_test--1.0.sql diff --git a/diskquota_test.control b/control/test/diskquota_test.control similarity index 100% rename from diskquota_test.control rename to control/test/diskquota_test.control diff --git a/diskquota.c b/src/diskquota.c similarity index 100% rename from diskquota.c rename to src/diskquota.c diff --git a/diskquota.h b/src/diskquota.h similarity index 100% rename from diskquota.h rename to src/diskquota.h diff --git a/diskquota_enum.h b/src/diskquota_enum.h similarity index 100% rename from diskquota_enum.h rename to src/diskquota_enum.h diff --git a/diskquota_utility.c b/src/diskquota_utility.c similarity index 100% rename from diskquota_utility.c rename to src/diskquota_utility.c diff --git a/enforcement.c b/src/enforcement.c similarity index 100% rename from enforcement.c rename to src/enforcement.c diff --git a/gp_activetable.c b/src/gp_activetable.c similarity index 100% rename from gp_activetable.c rename to src/gp_activetable.c diff --git a/gp_activetable.h b/src/gp_activetable.h similarity index 100% rename from gp_activetable.h rename to src/gp_activetable.h diff --git a/monitored_db.c b/src/monitored_db.c similarity index 100% rename from monitored_db.c rename to src/monitored_db.c diff --git a/quotamodel.c b/src/quotamodel.c similarity index 100% rename from quotamodel.c rename to src/quotamodel.c diff --git a/relation_cache.c b/src/relation_cache.c similarity index 100% rename from relation_cache.c rename to src/relation_cache.c diff --git a/relation_cache.h b/src/relation_cache.h similarity index 100% rename from relation_cache.h rename to src/relation_cache.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a2a3c4b7..ef754a0a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -50,9 +50,9 @@ RegressTarget_Add(isolation2 add_custom_target(install_test_extension COMMAND - cmake -E copy ${CMAKE_SOURCE_DIR}/diskquota_test.control ${PG_HOME}/share/postgresql/extension + cmake -E copy ${CMAKE_SOURCE_DIR}/control/test/diskquota_test.control ${PG_HOME}/share/postgresql/extension COMMAND - cmake -E copy ${CMAKE_SOURCE_DIR}/diskquota_test--1.0.sql ${PG_HOME}/share/postgresql/extension + cmake -E copy ${CMAKE_SOURCE_DIR}/control/test/diskquota_test--1.0.sql ${PG_HOME}/share/postgresql/extension ) add_custom_target(installcheck) From a15244f5c2e5618de335f0a4722b21c3fb16b768 Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Tue, 7 Mar 2023 17:32:43 +0800 Subject: [PATCH 14/31] Fix gpdb release binary regex (#311) The release candidate contains the build number now. Change the regex to match the latest release candidate for release pipeline. --- concourse/pipeline/res_def.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/concourse/pipeline/res_def.yml b/concourse/pipeline/res_def.yml index 54d05adf..ff2f666b 100644 --- a/concourse/pipeline/res_def.yml +++ b/concourse/pipeline/res_def.yml @@ -172,31 +172,31 @@ resources: source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.((9[0-8])|([1-8]?\d))\.(.*)-centos6.tar.gz + regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-centos6.tar.gz - name: bin_gpdb6_centos7 type: gcs source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.((9[0-8])|([1-8]?\d))\.(.*)-centos7.tar.gz + regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-centos7.tar.gz - name: bin_gpdb6_rhel8 type: gcs source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.((9[0-8])|([1-8]?\d))\.(.*)-rhel8.tar.gz + regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-rhel8.tar.gz - name: bin_gpdb6_ubuntu18 type: gcs source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.((9[0-8])|([1-8]?\d))\.(.*)-ubuntu18.04.tar.gz + regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-ubuntu18.04.tar.gz - name: bin_gpdb7_rhel8 type: gcs source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb7/greenplum-db-server-7\.((9[0-8])|([1-8]?\d))\.(.*)-rhel8.tar.gz + regexp: server/release-candidates/gpdb7/greenplum-db-server-7\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-rhel8.tar.gz # Diskquota releases - name: bin_diskquota_gpdb6_rhel6 From 83a1554dec20aba1558eb64ef4283a70426943b2 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Tue, 7 Mar 2023 17:50:17 +0800 Subject: [PATCH 15/31] Enable test_postmaster_restart (#309) The isolation2 test `test_postmaster_restart` is disabled because the postmaster start command is different between GPDB6 and GPDB7. We should enable this test by passing distinct commands for GPDB6 and GPDB7 to test_postmaster_restart.sql. Meanwhile, we can merge isolation2_schedule7 and isolation2_schedule to one. --- tests/CMakeLists.txt | 5 +- .../expected7/test_postmaster_restart.out | 162 ++++++++++++++++++ tests/isolation2/isolation2_schedule7 | 13 -- ...art.sql => test_postmaster_restart.in.sql} | 2 +- 4 files changed, 166 insertions(+), 16 deletions(-) create mode 100644 tests/isolation2/expected7/test_postmaster_restart.out delete mode 100644 tests/isolation2/isolation2_schedule7 rename tests/isolation2/sql/{test_postmaster_restart.sql => test_postmaster_restart.in.sql} (96%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ef754a0a..ee56ea15 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,13 +3,14 @@ include(${CMAKE_SOURCE_DIR}/cmake/Regress.cmake) list(APPEND isolation2_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/expected) list(APPEND regress_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/expected) if (${GP_MAJOR_VERSION} EQUAL 7) - set(EXPECTED_DIR_SUFFIX "7") list(APPEND isolation2_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/expected7) list(APPEND regress_expected_DIR ${CMAKE_CURRENT_SOURCE_DIR}/regress/expected7) # PLPYTHON_LANG_STR will be replaced by Regress.cmake set(PLPYTHON_LANG_STR "plpython3u") + set(POSTMASTER_START_CMD "pg_ctl -D $MASTER_DATA_DIRECTORY -w -o \"-c gp_role=dispatch\" start") else() set(PLPYTHON_LANG_STR "plpython2u") + set(POSTMASTER_START_CMD "pg_ctl -D $MASTER_DATA_DIRECTORY -w -o \"-E\" start") endif() set(exclude_fault_injector OFF) @@ -42,7 +43,7 @@ RegressTarget_Add(isolation2 EXPECTED_DIR ${isolation2_expected_DIR} RESULTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/results DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data - SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/isolation2_schedule${EXPECTED_DIR_SUFFIX} + SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/isolation2_schedule EXCLUDE_FAULT_INJECT_TEST ${exclude_fault_injector} REGRESS_OPTS --load-extension=gp_inject_fault diff --git a/tests/isolation2/expected7/test_postmaster_restart.out b/tests/isolation2/expected7/test_postmaster_restart.out new file mode 100644 index 00000000..bf842f49 --- /dev/null +++ b/tests/isolation2/expected7/test_postmaster_restart.out @@ -0,0 +1,162 @@ +!\retcode gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null; +-- start_ignore + +-- end_ignore +(exited with code 0) +!\retcode gpstop -u > /dev/null; +-- start_ignore + +-- end_ignore +(exited with code 0) + +1: CREATE SCHEMA postmaster_restart_s; +CREATE +1: SET search_path TO postmaster_restart_s; +SET + +1: SELECT diskquota.set_schema_quota('postmaster_restart_s', '1 MB'); + set_schema_quota +------------------ + +(1 row) +1: SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) + +-- expect fail +1: CREATE TABLE t1 AS SELECT generate_series(1,10000000); +ERROR: schema's disk space quota exceeded with name: 33502 (seg2 127.0.0.1:7004 pid=675047) +1q: ... + +-- launcher should exist +-- [p]ostgres is to filter out the pgrep itself +!\retcode pgrep -f "[p]ostgres.*launcher"; +-- start_ignore +673843 +673846 +673855 +673857 +673872 +673875 +673925 +673943 +673944 + +-- end_ignore +(exited with code 0) +-- bgworker should exist +!\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; +-- start_ignore +674189 + +-- end_ignore +(exited with code 0) + +-- stop postmaster +!\retcode pg_ctl -D $MASTER_DATA_DIRECTORY -w stop; +-- start_ignore +waiting for server to shut down.... done +server stopped + +-- end_ignore +(exited with code 0) + +-- launcher should be terminated +!\retcode pgrep -f "[p]ostgres.*launcher"; +-- start_ignore +673843 +673846 +673855 +673857 +673872 +673875 + +-- end_ignore +(exited with code 0) +-- bgworker should be terminated +!\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; +-- start_ignore + +-- end_ignore +(exited with code 1) + +-- start postmaster +-- -E needs to be changed to "-c gp_role=dispatch" for GPDB7 +-- See https://github.com/greenplum-db/gpdb/pull/9396 +!\retcode pg_ctl -D $MASTER_DATA_DIRECTORY -w -o "-c gp_role=dispatch" start; +-- start_ignore +waiting for server to start....2023-03-06 16:13:41.483928 CST,,,p675192,th987391872,,,,0,,,seg-1,,,,,"LOG","00000","starting PostgreSQL 12.12 (Greenplum Database 7.0.0-beta.1+dev.215.gb9adc4ece5 build dev) on x86_64-pc-linux-gnu, compiled by clang version 15.0.7, 64-bit",,,,,,,,"PostmasterMain","postmaster.c",1237, +2023-03-06 16:13:41.484093 CST,,,p675192,th987391872,,,,0,,,seg-1,,,,,"LOG","00000","listening on IPv4 address ""0.0.0.0"", port 7000",,,,,,,,"StreamServerPort","pqcomm.c",631, +2023-03-06 16:13:41.484153 CST,,,p675192,th987391872,,,,0,,,seg-1,,,,,"LOG","00000","listening on IPv6 address ""::"", port 7000",,,,,,,,"StreamServerPort","pqcomm.c",631, +2023-03-06 16:13:41.484241 CST,,,p675192,th987391872,,,,0,,,seg-1,,,,,"LOG","00000","listening on Unix socket ""/tmp/.s.PGSQL.7000""",,,,,,,,"StreamServerPort","pqcomm.c",625, +2023-03-06 16:13:41.510380 CST,,,p675192,th987391872,,,,0,,,seg-1,,,,,"LOG","00000","redirecting log output to logging collector process",,"Future log output will appear in directory ""log"".",,,,,,"SysLogger_Start","syslogger.c",929, + done +server started + +-- end_ignore +(exited with code 0) +-- Hopefully the bgworker can be started in 5 seconds +!\retcode sleep 5; +-- start_ignore + +-- end_ignore +(exited with code 0) + +-- launcher should be restarted +!\retcode pgrep -f "[p]ostgres.*launcher"; +-- start_ignore +673843 +673846 +673855 +673857 +673872 +673875 +675198 +675213 +675217 + +-- end_ignore +(exited with code 0) +-- bgworker should be restarted +!\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; +-- start_ignore +675239 + +-- end_ignore +(exited with code 0) + +1: SET search_path TO postmaster_restart_s; +SET +1: SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) +-- expect fail +1: CREATE TABLE t2 AS SELECT generate_series(1,10000000); +ERROR: schema's disk space quota exceeded with name: 33502 (seg2 127.0.0.1:7004 pid=679604) +-- enlarge the quota limits +1: SELECT diskquota.set_schema_quota('postmaster_restart_s', '100 MB'); + set_schema_quota +------------------ + +(1 row) +1: SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) +-- expect succeed +1: CREATE TABLE t3 AS SELECT generate_series(1,1000000); +CREATE 1000000 + +1: DROP SCHEMA postmaster_restart_s CASCADE; +DROP +1q: ... +!\retcode gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null; +-- start_ignore + +-- end_ignore +(exited with code 0) diff --git a/tests/isolation2/isolation2_schedule7 b/tests/isolation2/isolation2_schedule7 deleted file mode 100644 index 04e9b5c7..00000000 --- a/tests/isolation2/isolation2_schedule7 +++ /dev/null @@ -1,13 +0,0 @@ -test: config -test: test_create_extension -test: test_fast_quota_view -test: test_relation_size -test: test_rejectmap -test: test_vacuum -test: test_truncate -# test: test_postmaster_restart -test: test_worker_timeout -test: test_per_segment_config -test: test_relation_cache -test: test_drop_extension -test: reset_config diff --git a/tests/isolation2/sql/test_postmaster_restart.sql b/tests/isolation2/sql/test_postmaster_restart.in.sql similarity index 96% rename from tests/isolation2/sql/test_postmaster_restart.sql rename to tests/isolation2/sql/test_postmaster_restart.in.sql index 245fd91c..bd4def38 100644 --- a/tests/isolation2/sql/test_postmaster_restart.sql +++ b/tests/isolation2/sql/test_postmaster_restart.in.sql @@ -28,7 +28,7 @@ -- start postmaster -- -E needs to be changed to "-c gp_role=dispatch" for GPDB7 -- See https://github.com/greenplum-db/gpdb/pull/9396 -!\retcode pg_ctl -D $MASTER_DATA_DIRECTORY -w -o "-E" start; +!\retcode @POSTMASTER_START_CMD@; -- Hopefully the bgworker can be started in 5 seconds !\retcode sleep 5; From ea99897fca77f5f33f6738384364e34053f0fd51 Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Thu, 16 Mar 2023 11:10:50 +0800 Subject: [PATCH 16/31] Bump cmake min version to 3.20 (#313) Fix #312 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a79be595..38c64a98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.18) -# file(ARCHIVE_EXTRACT foo) need 3.18 +cmake_minimum_required(VERSION 3.20) +# cmake_path requires 3.20 project(diskquota) From a939bc078f9b041059ecb223504abb816753a3e4 Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Mon, 20 Mar 2023 10:22:33 +0800 Subject: [PATCH 17/31] Resource change for gpdb7 binary (#315) """ NOTICE: resource queue required -- using default resource queue "pg_default" """ has been removed in gpdb7 82851a0b85 . Ignore it in the tests. --- concourse/pipeline/job_def.lib.yml | 2 +- concourse/pipeline/res_def.yml | 8 ++++---- tests/init_file | 1 + .../regress/expected/test_clean_rejectmap_after_drop.out | 1 - tests/regress/expected/test_ctas_role.out | 1 - tests/regress/expected/test_ctas_tablespace_role.out | 1 - tests/regress/expected/test_mistake.out | 1 - tests/regress/expected/test_rename.out | 1 - tests/regress/expected/test_role.out | 3 --- tests/regress/expected/test_schema.out | 1 - tests/regress/expected/test_tablespace_role.out | 3 --- tests/regress/expected/test_tablespace_role_perseg.out | 3 --- tests/regress/expected/test_temp_role.out | 1 - upgrade_test/expected/1.0_set_quota.out | 1 - upgrade_test/expected/2.0_set_quota.out | 2 -- upgrade_test/expected/2.1_set_quota.out | 2 -- upgrade_test/expected/2.2_set_quota.out | 2 -- upgrade_test/init_file | 1 + 18 files changed, 7 insertions(+), 28 deletions(-) diff --git a/concourse/pipeline/job_def.lib.yml b/concourse/pipeline/job_def.lib.yml index 78119ad5..c206ca6e 100644 --- a/concourse/pipeline/job_def.lib.yml +++ b/concourse/pipeline/job_def.lib.yml @@ -66,7 +66,7 @@ build_type: #@ "Release" if release_build else "Debug" #@ def rhel8_gpdb7_conf(release_build=False): res_build_image: rocky8-gpdb7-image-build res_test_images: [rocky8-gpdb7-image-test, rhel8-gpdb7-image-test] -res_gpdb_bin: #@ "bin_gpdb7_rhel8" + ("" if release_build else "_debug") +res_gpdb_bin: #@ "bin_gpdb7_el8" + ("" if release_build else "_debug") res_diskquota_bin: bin_diskquota_gpdb7_rhel8 res_intermediates_bin: #@ inter_bin_name("bin_diskquota_gpdb7_rhel8_intermediates", release_build) release_bin: bin_diskquota_gpdb7_rhel8_release diff --git a/concourse/pipeline/res_def.yml b/concourse/pipeline/res_def.yml index ff2f666b..4e6578d8 100644 --- a/concourse/pipeline/res_def.yml +++ b/concourse/pipeline/res_def.yml @@ -158,12 +158,12 @@ resources: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) regexp: server/published/gpdb6/server-rc-(.*)-ubuntu18.04_x86_64.debug.tar.gz -- name: bin_gpdb7_rhel8_debug +- name: bin_gpdb7_el8_debug type: gcs source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/published/main/server-rc-(.*)-rhel8_x86_64.debug.tar.gz + regexp: server/published/main/server-rc-(.*)-el8_x86_64.debug.tar.gz # Latest release candidates, no fault-injector, no assertion: # --disable-debug-extensions --disable-tap-tests --enable-ic-proxy @@ -191,12 +191,12 @@ resources: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) regexp: server/release-candidates/gpdb6/greenplum-db-server-6\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-ubuntu18.04.tar.gz -- name: bin_gpdb7_rhel8 +- name: bin_gpdb7_el8 type: gcs source: bucket: pivotal-gpdb-concourse-resources-prod json_key: ((concourse-gcs-resources-service-account-key)) - regexp: server/release-candidates/gpdb7/greenplum-db-server-7\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-rhel8.tar.gz + regexp: server/release-candidates/gpdb7/greenplum-db-server-7\.([0-9]|([1-8][0-9])|(9[0-8]))\..*-dev.*-el8.tar.gz # Diskquota releases - name: bin_diskquota_gpdb6_rhel6 diff --git a/tests/init_file b/tests/init_file index ff2ea6bf..e1b5928c 100644 --- a/tests/init_file +++ b/tests/init_file @@ -9,6 +9,7 @@ m/WARNING: \[diskquota\] worker not found for database.*/ m/WARNING: \[diskquota\] database .* not found for getting epoch .*/ m/^NOTICE: CREATE TABLE will create partition */ m/^WARNING: skipping .* cannot calculate this foreign table size.*/ +m/^NOTICE: resource queue required -- using default resource queue "pg_default"/ -- end_matchignore -- start_matchsubs diff --git a/tests/regress/expected/test_clean_rejectmap_after_drop.out b/tests/regress/expected/test_clean_rejectmap_after_drop.out index 2c25b6b8..4da3507c 100644 --- a/tests/regress/expected/test_clean_rejectmap_after_drop.out +++ b/tests/regress/expected/test_clean_rejectmap_after_drop.out @@ -4,7 +4,6 @@ CREATE EXTENSION diskquota; \! gpconfig -c "diskquota.hard_limit" -v "on" > /dev/null \! gpstop -u > /dev/null CREATE ROLE r; -NOTICE: resource queue required -- using default resource queue "pg_default" SELECT diskquota.set_role_quota('r', '1MB'); set_role_quota ---------------- diff --git a/tests/regress/expected/test_ctas_role.out b/tests/regress/expected/test_ctas_role.out index be011529..d6452140 100644 --- a/tests/regress/expected/test_ctas_role.out +++ b/tests/regress/expected/test_ctas_role.out @@ -4,7 +4,6 @@ \! gpstop -u > /dev/null -- end_ignore CREATE ROLE hardlimit_r; -NOTICE: resource queue required -- using default resource queue "pg_default" SELECT diskquota.set_role_quota('hardlimit_r', '1MB'); set_role_quota ---------------- diff --git a/tests/regress/expected/test_ctas_tablespace_role.out b/tests/regress/expected/test_ctas_tablespace_role.out index 6443c3bd..adc0d95d 100644 --- a/tests/regress/expected/test_ctas_tablespace_role.out +++ b/tests/regress/expected/test_ctas_tablespace_role.out @@ -9,7 +9,6 @@ DROP TABLESPACE IF EXISTS ctas_rolespc; NOTICE: tablespace "ctas_rolespc" does not exist, skipping CREATE TABLESPACE ctas_rolespc LOCATION '/tmp/ctas_rolespc'; CREATE ROLE hardlimit_r; -NOTICE: resource queue required -- using default resource queue "pg_default" GRANT USAGE ON SCHEMA diskquota TO hardlimit_r; GRANT ALL ON TABLESPACE ctas_rolespc TO hardlimit_r; SELECT diskquota.set_role_tablespace_quota('hardlimit_r', 'ctas_rolespc', '1 MB'); diff --git a/tests/regress/expected/test_mistake.out b/tests/regress/expected/test_mistake.out index fab4c6eb..bd11eb5f 100644 --- a/tests/regress/expected/test_mistake.out +++ b/tests/regress/expected/test_mistake.out @@ -14,7 +14,6 @@ ERROR: disk quota can not be set to 0 MB DROP ROLE IF EXISTS rmistake; NOTICE: role "rmistake" does not exist, skipping CREATE ROLE rmistake; -NOTICE: resource queue required -- using default resource queue "pg_default" select diskquota.set_role_quota('rmistake', '0 MB'); ERROR: disk quota can not be set to 0 MB -- start_ignore diff --git a/tests/regress/expected/test_rename.out b/tests/regress/expected/test_rename.out index ecd470ea..57573b42 100644 --- a/tests/regress/expected/test_rename.out +++ b/tests/regress/expected/test_rename.out @@ -37,7 +37,6 @@ DROP SCHEMA srs2; -- test rename role CREATE SCHEMA srr1; CREATE ROLE srerole NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" SELECT diskquota.set_role_quota('srerole', '1MB'); set_role_quota ---------------- diff --git a/tests/regress/expected/test_role.out b/tests/regress/expected/test_role.out index f4d6690c..3f18ab80 100644 --- a/tests/regress/expected/test_role.out +++ b/tests/regress/expected/test_role.out @@ -2,9 +2,7 @@ CREATE SCHEMA srole; SET search_path TO srole; CREATE ROLE u1 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE ROLE u2 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE TABLE b (t TEXT) DISTRIBUTED BY (t); ALTER TABLE b OWNER TO u1; CREATE TABLE b2 (t TEXT) DISTRIBUTED BY (t); @@ -121,7 +119,6 @@ select diskquota.set_role_quota(:'rolname', '-1mb'); (1 row) CREATE ROLE "Tn" NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" SELECT diskquota.set_role_quota('Tn', '-1 MB'); -- fail ERROR: role "tn" does not exist SELECT diskquota.set_role_quota('"tn"', '-1 MB'); -- fail diff --git a/tests/regress/expected/test_schema.out b/tests/regress/expected/test_schema.out index 866b4b3e..a85d1615 100644 --- a/tests/regress/expected/test_schema.out +++ b/tests/regress/expected/test_schema.out @@ -42,7 +42,6 @@ CREATE SCHEMA badquota; DROP ROLE IF EXISTS testbody; NOTICE: role "testbody" does not exist, skipping CREATE ROLE testbody; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE TABLE badquota.t1(i INT) DISTRIBUTED BY (i); ALTER TABLE badquota.t1 OWNER TO testbody; INSERT INTO badquota.t1 SELECT generate_series(0, 100000); diff --git a/tests/regress/expected/test_tablespace_role.out b/tests/regress/expected/test_tablespace_role.out index beed1ae8..1d1d165c 100644 --- a/tests/regress/expected/test_tablespace_role.out +++ b/tests/regress/expected/test_tablespace_role.out @@ -12,9 +12,7 @@ NOTICE: role "rolespcu1" does not exist, skipping DROP ROLE IF EXISTS rolespcu2; NOTICE: role "rolespcu2" does not exist, skipping CREATE ROLE rolespcu1 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE ROLE rolespcu2 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE TABLE b (t TEXT) TABLESPACE rolespc DISTRIBUTED BY (t); CREATE TABLE b2 (t TEXT) TABLESPACE rolespc DISTRIBUTED BY (t); ALTER TABLE b2 OWNER TO rolespcu1; @@ -163,7 +161,6 @@ ERROR: Can not set disk quota for system owner: sa DROP ROLE IF EXISTS "Rolespcu3"; NOTICE: role "Rolespcu3" does not exist, skipping CREATE ROLE "Rolespcu3" NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" DROP TABLESPACE IF EXISTS "Rolespc3"; NOTICE: tablespace "Rolespc3" does not exist, skipping CREATE TABLESPACE "Rolespc3" LOCATION '/tmp/rolespc3'; diff --git a/tests/regress/expected/test_tablespace_role_perseg.out b/tests/regress/expected/test_tablespace_role_perseg.out index c3003032..eafbb92a 100644 --- a/tests/regress/expected/test_tablespace_role_perseg.out +++ b/tests/regress/expected/test_tablespace_role_perseg.out @@ -12,9 +12,7 @@ NOTICE: role "rolespc_persegu1" does not exist, skipping DROP ROLE IF EXISTS rolespc_persegu2; NOTICE: role "rolespc_persegu2" does not exist, skipping CREATE ROLE rolespc_persegu1 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE ROLE rolespc_persegu2 NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" CREATE TABLE b (t TEXT) TABLESPACE rolespc_perseg DISTRIBUTED BY (t); ALTER TABLE b OWNER TO rolespc_persegu1; SELECT diskquota.set_role_tablespace_quota('rolespc_persegu1', 'rolespc_perseg', '1 MB'); @@ -213,7 +211,6 @@ DROP TABLESPACE IF EXISTS "Rolespc_perseg3"; NOTICE: tablespace "Rolespc_perseg3" does not exist, skipping CREATE TABLESPACE "Rolespc_perseg3" LOCATION '/tmp/rolespc_perseg3'; CREATE ROLE "Rolespc_persegu3" NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" SELECT diskquota.set_role_tablespace_quota('"Rolespc_persegu3"', '"Rolespc_perseg3"', '-1 MB'); set_role_tablespace_quota --------------------------- diff --git a/tests/regress/expected/test_temp_role.out b/tests/regress/expected/test_temp_role.out index 5a2462a5..7896ec17 100644 --- a/tests/regress/expected/test_temp_role.out +++ b/tests/regress/expected/test_temp_role.out @@ -1,7 +1,6 @@ -- Test temp table restrained by role id CREATE SCHEMA strole; CREATE ROLE u3temp NOLOGIN; -NOTICE: resource queue required -- using default resource queue "pg_default" SET search_path TO strole; SELECT diskquota.set_role_quota('u3temp', '1MB'); set_role_quota diff --git a/upgrade_test/expected/1.0_set_quota.out b/upgrade_test/expected/1.0_set_quota.out index d8d661fc..32ffd2da 100644 --- a/upgrade_test/expected/1.0_set_quota.out +++ b/upgrade_test/expected/1.0_set_quota.out @@ -18,7 +18,6 @@ insert into s1.a select generate_series(1, 10000000); -- ok, but should fail aft -- role quota create schema srole; create role u1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create table srole.b (t text) distributed by (t); alter table srole.b owner to u1; select diskquota.set_role_quota('u1', '1 MB'); diff --git a/upgrade_test/expected/2.0_set_quota.out b/upgrade_test/expected/2.0_set_quota.out index ef0f2b04..ce97cae5 100644 --- a/upgrade_test/expected/2.0_set_quota.out +++ b/upgrade_test/expected/2.0_set_quota.out @@ -18,7 +18,6 @@ insert into s1.a select generate_series(1, 10000000); -- ok. -- role quota create schema srole; create role u1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create table srole.b (t text) distributed by (t); alter table srole.b owner to u1; select diskquota.set_role_quota('u1', '1 MB'); @@ -44,7 +43,6 @@ insert into spcs1.a select generate_series(1,100000); -- ok. \! mkdir -p /tmp/rolespc create tablespace rolespc location '/tmp/rolespc'; create role rolespcu1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create schema rolespcrole; create table rolespcrole.b (t text) tablespace rolespc distributed by (t); alter table rolespcrole.b owner to rolespcu1; diff --git a/upgrade_test/expected/2.1_set_quota.out b/upgrade_test/expected/2.1_set_quota.out index 5d34aad0..b40938d6 100644 --- a/upgrade_test/expected/2.1_set_quota.out +++ b/upgrade_test/expected/2.1_set_quota.out @@ -18,7 +18,6 @@ insert into s1.a select generate_series(1, 10000000); -- ok. -- role quota create schema srole; create role u1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create table srole.b (t text) distributed by (t); alter table srole.b owner to u1; select diskquota.set_role_quota('u1', '1 MB'); @@ -44,7 +43,6 @@ insert into spcs1.a select generate_series(1,100000); -- ok. \! mkdir -p /tmp/rolespc create tablespace rolespc location '/tmp/rolespc'; create role rolespcu1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create schema rolespcrole; create table rolespcrole.b (t text) tablespace rolespc distributed by (t); alter table rolespcrole.b owner to rolespcu1; diff --git a/upgrade_test/expected/2.2_set_quota.out b/upgrade_test/expected/2.2_set_quota.out index 58d8cc0a..400f3e54 100644 --- a/upgrade_test/expected/2.2_set_quota.out +++ b/upgrade_test/expected/2.2_set_quota.out @@ -18,7 +18,6 @@ insert into s1.a select generate_series(1, 10000000); -- ok. -- role quota create schema srole; create role u1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create table srole.b (t text) distributed by (t); alter table srole.b owner to u1; select diskquota.set_role_quota('u1', '1 MB'); @@ -44,7 +43,6 @@ insert into spcs1.a select generate_series(1,100000); -- ok. \! mkdir -p /tmp/rolespc create tablespace rolespc location '/tmp/rolespc'; create role rolespcu1 nologin; -NOTICE: resource queue required -- using default resource queue "pg_default" create schema rolespcrole; create table rolespcrole.b (t text) tablespace rolespc distributed by (t); alter table rolespcrole.b owner to rolespcu1; diff --git a/upgrade_test/init_file b/upgrade_test/init_file index 5261e4ef..a764e9d5 100644 --- a/upgrade_test/init_file +++ b/upgrade_test/init_file @@ -3,6 +3,7 @@ -- Individual tests can contain additional patterns specific to the test. -- start_matchignore +m/^NOTICE: resource queue required -- using default resource queue "pg_default"/ -- end_matchignore -- start_matchsubs m/diskquota.c:\d+\)/ From 9df0f2eefb225b71bdd44e9889767881bfabd898 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Mon, 27 Mar 2023 11:18:23 +0800 Subject: [PATCH 18/31] Fix bug: bgworker enters infinite loop after receiving notices from QE. (#314) We should not initialize the MyProcPort in bgworker, which will cause the database name to not be automatically added to the log message. In normal, the log printed from the bgworker does not contain the database name but contains the bgworker's pid. In order to facilitate debugging, we should print the database name every BGWORKER_LOG_TIME to ensure that we can find the database name by the bgworker's pid in the log file. Co-authored-by: Chen Mulong --- src/diskquota.c | 26 ++++++-- src/gp_activetable.c | 7 +++ .../expected/test_ereport_from_seg.out | 62 +++++++++++++++++++ tests/isolation2/isolation2_schedule | 1 + .../isolation2/sql/test_ereport_from_seg.sql | 26 ++++++++ .../expected/test_readiness_logged.out | 32 ++++++++-- tests/regress/sql/test_readiness_logged.sql | 31 ++++++++-- 7 files changed, 171 insertions(+), 14 deletions(-) create mode 100644 tests/isolation2/expected/test_ereport_from_seg.out create mode 100644 tests/isolation2/sql/test_ereport_from_seg.sql diff --git a/src/diskquota.c b/src/diskquota.c index aa24b6cd..0cd4a708 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -90,7 +90,8 @@ pg_atomic_uint32 *diskquota_table_size_entry_num; static DiskquotaLauncherShmemStruct *DiskquotaLauncherShmem; -#define MIN_SLEEPTIME 100 /* milliseconds */ +#define MIN_SLEEPTIME 100 /* milliseconds */ +#define BGWORKER_LOG_TIME 3600000 /* milliseconds */ /* * bgworker handles, in launcher local memory, @@ -322,9 +323,6 @@ disk_quota_worker_main(Datum main_arg) { char *dbname = MyBgworkerEntry->bgw_name; - MyProcPort = (Port *)calloc(1, sizeof(Port)); - MyProcPort->database_name = dbname; /* To show the database in the log */ - /* Disable ORCA to avoid fallback */ optimizer = false; @@ -480,11 +478,29 @@ disk_quota_worker_main(Datum main_arg) } if (!MyWorkerInfo->dbEntry->inited) update_monitordb_status(MyWorkerInfo->dbEntry->dbid, DB_RUNNING); - bool is_gang_destroyed = false; + + bool is_gang_destroyed = false; + TimestampTz log_start_timestamp = GetCurrentTimestamp(); + TimestampTz log_end_timestamp; + ereport(LOG, (errmsg("[diskquota] disk quota worker process is monitoring database:%s", dbname))); + while (!got_sigterm) { int rc; + /* + * The log printed from the bgworker does not contain the database name + * but contains the bgworker's pid. We should print the database name + * every BGWORKER_LOG_TIME to ensure that we can find the database name + * by the bgworker's pid in the log file. + */ + log_end_timestamp = GetCurrentTimestamp(); + if (TimestampDifferenceExceeds(log_start_timestamp, log_end_timestamp, BGWORKER_LOG_TIME)) + { + ereport(LOG, (errmsg("[diskquota] disk quota worker process is monitoring database:%s", dbname))); + log_start_timestamp = log_end_timestamp; + } + SIMPLE_FAULT_INJECTOR("diskquota_worker_main"); if (!diskquota_is_paused()) { diff --git a/src/gp_activetable.c b/src/gp_activetable.c index 1b2d6842..1002dbd1 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -430,6 +430,13 @@ diskquota_fetch_table_stat(PG_FUNCTION_ARGS) DiskQuotaSetOFCache *cache = NULL; DiskQuotaActiveTableEntry *results_entry = NULL; +#ifdef FAULT_INJECTOR + if (SIMPLE_FAULT_INJECTOR("ereport_warning_from_segment") == FaultInjectorTypeSkip) + { + ereport(WARNING, (errmsg("[Fault Injector] This is a warning reported from segment"))); + } +#endif + /* Init the container list in the first call and get the results back */ if (SRF_IS_FIRSTCALL()) { diff --git a/tests/isolation2/expected/test_ereport_from_seg.out b/tests/isolation2/expected/test_ereport_from_seg.out new file mode 100644 index 00000000..776bfac6 --- /dev/null +++ b/tests/isolation2/expected/test_ereport_from_seg.out @@ -0,0 +1,62 @@ +CREATE SCHEMA efs1; +CREATE +SELECT diskquota.set_schema_quota('efs1', '1MB'); + set_schema_quota +------------------ + +(1 row) +CREATE TABLE efs1.t(i int); +CREATE + +INSERT INTO efs1.t SELECT generate_series(1, 10000); +INSERT 10000 +-- wait for refresh of diskquota and check the quota size +SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) +SELECT schema_name, quota_in_mb, nspsize_in_bytes FROM diskquota.show_fast_schema_quota_view WHERE schema_name = 'efs1'; + schema_name | quota_in_mb | nspsize_in_bytes +-------------+-------------+------------------ + efs1 | 1 | 688128 +(1 row) + +-- Enable check quota by relfilenode on seg0. +SELECT gp_inject_fault_infinite('ereport_warning_from_segment', 'skip', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) + +SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) +INSERT INTO efs1.t SELECT generate_series(1, 10000); +INSERT 10000 + +-- wait for refresh of diskquota and check whether the quota size changes +SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) +SELECT schema_name, quota_in_mb, nspsize_in_bytes FROM diskquota.show_fast_schema_quota_view WHERE schema_name = 'efs1'; + schema_name | quota_in_mb | nspsize_in_bytes +-------------+-------------+------------------ + efs1 | 1 | 1081344 +(1 row) + +DROP TABLE efs1.t; +DROP +DROP SCHEMA efs1; +DROP + +-- Reset fault injection points set by us at the top of this test. +SELECT gp_inject_fault_infinite('ereport_warning_from_segment', 'reset', dbid) FROM gp_segment_configuration WHERE role='p' AND content=0; + gp_inject_fault_infinite +-------------------------- + Success: +(1 row) diff --git a/tests/isolation2/isolation2_schedule b/tests/isolation2/isolation2_schedule index 090ea9ad..090c5cc5 100644 --- a/tests/isolation2/isolation2_schedule +++ b/tests/isolation2/isolation2_schedule @@ -9,5 +9,6 @@ test: test_postmaster_restart test: test_worker_timeout test: test_per_segment_config test: test_relation_cache +test: test_ereport_from_seg test: test_drop_extension test: reset_config diff --git a/tests/isolation2/sql/test_ereport_from_seg.sql b/tests/isolation2/sql/test_ereport_from_seg.sql new file mode 100644 index 00000000..79cd25b2 --- /dev/null +++ b/tests/isolation2/sql/test_ereport_from_seg.sql @@ -0,0 +1,26 @@ +CREATE SCHEMA efs1; +SELECT diskquota.set_schema_quota('efs1', '1MB'); +CREATE TABLE efs1.t(i int); + +INSERT INTO efs1.t SELECT generate_series(1, 10000); +-- wait for refresh of diskquota and check the quota size +SELECT diskquota.wait_for_worker_new_epoch(); +SELECT schema_name, quota_in_mb, nspsize_in_bytes FROM diskquota.show_fast_schema_quota_view WHERE schema_name = 'efs1'; + +-- Enable check quota by relfilenode on seg0. +SELECT gp_inject_fault_infinite('ereport_warning_from_segment', 'skip', dbid) + FROM gp_segment_configuration WHERE role='p' AND content=0; + +SELECT diskquota.wait_for_worker_new_epoch(); +INSERT INTO efs1.t SELECT generate_series(1, 10000); + +-- wait for refresh of diskquota and check whether the quota size changes +SELECT diskquota.wait_for_worker_new_epoch(); +SELECT schema_name, quota_in_mb, nspsize_in_bytes FROM diskquota.show_fast_schema_quota_view WHERE schema_name = 'efs1'; + +DROP TABLE efs1.t; +DROP SCHEMA efs1; + +-- Reset fault injection points set by us at the top of this test. +SELECT gp_inject_fault_infinite('ereport_warning_from_segment', 'reset', dbid) + FROM gp_segment_configuration WHERE role='p' AND content=0; diff --git a/tests/regress/expected/test_readiness_logged.out b/tests/regress/expected/test_readiness_logged.out index c798f08b..ed303e70 100644 --- a/tests/regress/expected/test_readiness_logged.out +++ b/tests/regress/expected/test_readiness_logged.out @@ -1,5 +1,27 @@ CREATE DATABASE test_readiness_logged; \c test_readiness_logged +-- Get bgworker's log by database name. +-- 1. select bgworker pid by database name. +-- 2. select logmessage by bgworker pid. +CREATE VIEW logmessage_count_view AS WITH logp AS( + SELECT + MAX(logpid) as max_logpid + FROM + gp_toolkit.__gp_log_master_ext + WHERE + position( + '[diskquota] start disk quota worker process to monitor database' in logmessage + ) > 0 + AND position(current_database() in logmessage) > 0 +) +SELECT + count(*) +FROM + gp_toolkit.__gp_log_master_ext, + logp +WHERE + logmessage = '[diskquota] diskquota is not ready' + and logpid = max_logpid; CREATE TABLE t (i int) DISTRIBUTED BY (i); CREATE EXTENSION diskquota; WARNING: [diskquota] diskquota is not ready because current database is not empty @@ -11,8 +33,8 @@ SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY' t (1 row) -SELECT count(*) FROM gp_toolkit.gp_log_database -WHERE logmessage = '[diskquota] diskquota is not ready'; +-- logmessage count should be 1 +SELECT * FROM logmessage_count_view; count ------- 1 @@ -26,11 +48,11 @@ SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY' t (1 row) -SELECT count(*) FROM gp_toolkit.gp_log_database -WHERE logmessage = '[diskquota] diskquota is not ready'; +-- logmessage count should be 1 +SELECT * FROM logmessage_count_view; count ------- - 2 + 1 (1 row) DROP EXTENSION diskquota; diff --git a/tests/regress/sql/test_readiness_logged.sql b/tests/regress/sql/test_readiness_logged.sql index 3151393c..56273327 100644 --- a/tests/regress/sql/test_readiness_logged.sql +++ b/tests/regress/sql/test_readiness_logged.sql @@ -1,21 +1,44 @@ CREATE DATABASE test_readiness_logged; \c test_readiness_logged +-- Get bgworker's log by database name. +-- 1. select bgworker pid by database name. +-- 2. select logmessage by bgworker pid. +CREATE VIEW logmessage_count_view AS WITH logp AS( + SELECT + MAX(logpid) as max_logpid + FROM + gp_toolkit.__gp_log_master_ext + WHERE + position( + '[diskquota] start disk quota worker process to monitor database' in logmessage + ) > 0 + AND position(current_database() in logmessage) > 0 +) +SELECT + count(*) +FROM + gp_toolkit.__gp_log_master_ext, + logp +WHERE + logmessage = '[diskquota] diskquota is not ready' + and logpid = max_logpid; + CREATE TABLE t (i int) DISTRIBUTED BY (i); CREATE EXTENSION diskquota; CREATE EXTENSION diskquota_test; SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY'');'); -SELECT count(*) FROM gp_toolkit.gp_log_database -WHERE logmessage = '[diskquota] diskquota is not ready'; +-- logmessage count should be 1 +SELECT * FROM logmessage_count_view; \! gpstop -raf > /dev/null \c SELECT diskquota_test.wait('SELECT diskquota_test.check_cur_db_status(''UNREADY'');'); -SELECT count(*) FROM gp_toolkit.gp_log_database -WHERE logmessage = '[diskquota] diskquota is not ready'; +-- logmessage count should be 1 +SELECT * FROM logmessage_count_view; DROP EXTENSION diskquota; From edbfd5ebc15fccc66965e367c4a885e68e15b744 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Thu, 6 Apr 2023 09:46:02 +0800 Subject: [PATCH 19/31] Ignore some hint/notice for GPDB7 (#328) --- tests/init_file | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/init_file b/tests/init_file index e1b5928c..613ebf85 100644 --- a/tests/init_file +++ b/tests/init_file @@ -10,6 +10,8 @@ m/WARNING: \[diskquota\] database .* not found for getting epoch .*/ m/^NOTICE: CREATE TABLE will create partition */ m/^WARNING: skipping .* cannot calculate this foreign table size.*/ m/^NOTICE: resource queue required -- using default resource queue "pg_default"/ +m/NOTICE: One or more columns in the following table\(s\) do not have statistics: / +m/HINT: For non-partitioned tables, run analyze .+\. For partitioned tables, run analyze rootpartition .+\. See log for columns missing statistics\./ -- end_matchignore -- start_matchsubs From 685b52dcaaf2a4846c351f951bc944c3f8c17ed1 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Thu, 6 Apr 2023 11:07:48 +0800 Subject: [PATCH 20/31] fix flaky test: test_appendonly (#327) --- tests/regress/expected/test_appendonly.out | 4 ++-- tests/regress/expected7/test_appendonly.out | 4 ++-- tests/regress/sql/test_appendonly.sql | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/regress/expected/test_appendonly.out b/tests/regress/expected/test_appendonly.out index d0c465af..d7dfc2ee 100644 --- a/tests/regress/expected/test_appendonly.out +++ b/tests/regress/expected/test_appendonly.out @@ -47,14 +47,14 @@ SELECT pg_table_size('t_aoco'); (1 row) -- 2. Test that we are able to perform quota limit on appendonly tables. -SELECT diskquota.set_schema_quota('s_appendonly', '1 MB'); +SELECT diskquota.set_schema_quota('s_appendonly', '1.2 MB'); set_schema_quota ------------------ (1 row) -- expect success. -INSERT INTO t_ao SELECT generate_series(1, 1000); +INSERT INTO t_ao SELECT generate_series(1, 10000); SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch --------------------------- diff --git a/tests/regress/expected7/test_appendonly.out b/tests/regress/expected7/test_appendonly.out index d324bd76..c2a61cbb 100644 --- a/tests/regress/expected7/test_appendonly.out +++ b/tests/regress/expected7/test_appendonly.out @@ -47,14 +47,14 @@ SELECT pg_table_size('t_aoco'); (1 row) -- 2. Test that we are able to perform quota limit on appendonly tables. -SELECT diskquota.set_schema_quota('s_appendonly', '1 MB'); +SELECT diskquota.set_schema_quota('s_appendonly', '1.2 MB'); set_schema_quota ------------------ (1 row) -- expect success. -INSERT INTO t_ao SELECT generate_series(1, 1000); +INSERT INTO t_ao SELECT generate_series(1, 10000); SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch --------------------------- diff --git a/tests/regress/sql/test_appendonly.sql b/tests/regress/sql/test_appendonly.sql index 88529347..40337eba 100644 --- a/tests/regress/sql/test_appendonly.sql +++ b/tests/regress/sql/test_appendonly.sql @@ -30,9 +30,9 @@ SELECT tableid::regclass, size SELECT pg_table_size('t_aoco'); -- 2. Test that we are able to perform quota limit on appendonly tables. -SELECT diskquota.set_schema_quota('s_appendonly', '1 MB'); +SELECT diskquota.set_schema_quota('s_appendonly', '1.2 MB'); -- expect success. -INSERT INTO t_ao SELECT generate_series(1, 1000); +INSERT INTO t_ao SELECT generate_series(1, 10000); SELECT diskquota.wait_for_worker_new_epoch(); From e9cadf2f31db86724219b9300ecc2c679c301567 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Thu, 6 Apr 2023 11:10:53 +0800 Subject: [PATCH 21/31] Add dbname to DiskQuotaWorkerEntry (#326) Previously, we passed dbname by bgw_name to bgworker. But refer to https://github.com/greenplum-db/gpdb/blob/f182228992b62e2023e2fac5b4971406abd35c9d/src/backend/postmaster/bgworker.c#L385-L386, bgw_name is copied by ascii_safe_strlcpy(), which replaces non-ASCII bytes with '?'. If the database name is non-ASCII, the bgworker can not connect to the correct database and raises an error. issue: #323 . To solve this problem, we should pass dbname by bgw_main_arg to the main function of the bgworker. --- src/diskquota.c | 14 +++++++--- src/diskquota.h | 3 +- tests/regress/diskquota_schedule | 1 + .../regress/expected/test_dbname_encoding.out | 28 +++++++++++++++++++ tests/regress/sql/test_dbname_encoding.sql | 21 ++++++++++++++ 5 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 tests/regress/expected/test_dbname_encoding.out create mode 100644 tests/regress/sql/test_dbname_encoding.sql diff --git a/src/diskquota.c b/src/diskquota.c index 0cd4a708..b46f39f3 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -321,7 +321,12 @@ define_guc_variables(void) void disk_quota_worker_main(Datum main_arg) { - char *dbname = MyBgworkerEntry->bgw_name; + char dbname[NAMEDATALEN]; + + MyWorkerInfo = (DiskQuotaWorkerEntry *)DatumGetPointer(MyBgworkerEntry->bgw_main_arg); + Assert(MyWorkerInfo != NULL); + + memcpy(dbname, MyWorkerInfo->dbname.data, NAMEDATALEN); /* Disable ORCA to avoid fallback */ optimizer = false; @@ -332,8 +337,6 @@ disk_quota_worker_main(Datum main_arg) pqsignal(SIGTERM, disk_quota_sigterm); pqsignal(SIGUSR1, disk_quota_sigusr1); - MyWorkerInfo = (DiskQuotaWorkerEntry *)DatumGetPointer(MyBgworkerEntry->bgw_main_arg); - Assert(MyWorkerInfo != NULL); if (!MyWorkerInfo->dbEntry->inited) ereport(LOG, (errmsg("[diskquota] start disk quota worker process to monitor database:%s", dbname))); /* @@ -1381,7 +1384,10 @@ start_worker(DiskquotaDBEntry *dbEntry) result = INVALID_DB; goto Failed; } - snprintf(worker.bgw_name, sizeof(worker.bgw_name), "%s", dbname); + /* We do not need to get lock here, since this entry is not used by other process. */ + namestrcpy(&(dq_worker->dbname), dbname); + + snprintf(worker.bgw_name, sizeof(worker.bgw_name), "diskquota bgworker %d", dbEntry->dbid); pfree(dbname); /* set bgw_notify_pid so that we can use WaitForBackgroundWorkerStartup */ diff --git a/src/diskquota.h b/src/diskquota.h index 0bd5ab30..f044773b 100644 --- a/src/diskquota.h +++ b/src/diskquota.h @@ -185,7 +185,8 @@ struct DiskQuotaWorkerEntry { dlist_node node; // the double linked list header - int id; // starts from 0, -1 means invalid + int id; // starts from 0, -1 means invalid + NameData dbname; // the database name. It does not need to be reset, when dbEntry == NULL, dbname is not valid. DiskquotaDBEntry *dbEntry; // pointer to shared memory. DiskquotaLauncherShmem->dbArray }; diff --git a/tests/regress/diskquota_schedule b/tests/regress/diskquota_schedule index 7722765d..9805a8e4 100644 --- a/tests/regress/diskquota_schedule +++ b/tests/regress/diskquota_schedule @@ -41,5 +41,6 @@ test: test_default_tablespace test: test_tablespace_diff_schema test: test_worker_schedule test: test_worker_schedule_exception +test: test_dbname_encoding test: test_drop_extension test: reset_config diff --git a/tests/regress/expected/test_dbname_encoding.out b/tests/regress/expected/test_dbname_encoding.out new file mode 100644 index 00000000..d7b31373 --- /dev/null +++ b/tests/regress/expected/test_dbname_encoding.out @@ -0,0 +1,28 @@ +-- create a database with non-ascii characters +CREATE DATABASE 数据库1; +\c 数据库1 +CREATE EXTENSION diskquota; +SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) + +-- check whether current database name is logged. +SELECT + count(logpid) > 0 +FROM + gp_toolkit.__gp_log_master_ext +WHERE + position( + '[diskquota] start disk quota worker process to monitor database' in logmessage + ) > 0 + AND position(current_database() in logmessage) > 0; + ?column? +---------- + t +(1 row) + +DROP EXTENSION diskquota; +\c contrib_regression +DROP DATABASE 数据库1; diff --git a/tests/regress/sql/test_dbname_encoding.sql b/tests/regress/sql/test_dbname_encoding.sql new file mode 100644 index 00000000..408b6a0a --- /dev/null +++ b/tests/regress/sql/test_dbname_encoding.sql @@ -0,0 +1,21 @@ +-- create a database with non-ascii characters +CREATE DATABASE 数据库1; + +\c 数据库1 + +CREATE EXTENSION diskquota; +SELECT diskquota.wait_for_worker_new_epoch(); +-- check whether current database name is logged. +SELECT + count(logpid) > 0 +FROM + gp_toolkit.__gp_log_master_ext +WHERE + position( + '[diskquota] start disk quota worker process to monitor database' in logmessage + ) > 0 + AND position(current_database() in logmessage) > 0; + +DROP EXTENSION diskquota; +\c contrib_regression +DROP DATABASE 数据库1; \ No newline at end of file From e2ab156e0f7b3320245fcdde900eb3b172ed24ba Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Thu, 6 Apr 2023 14:14:04 +0800 Subject: [PATCH 22/31] Replace SPI_execute with SPI_cursor_fetch (#322) The result buffer of SPI_execute is limited to 1GB. If the number of rows in diskquota.table_size exceeds 3 * 10^7 (500 segments with 60000 tables for example), SPI_execute("select tableid, size, segid from diskquota.table_size") will raise an error for invalid memory alloc request size 1073741824 (context 'SPI TupTable'). We should fetch table-size entries by portions. Replace SPI_execute() with SPI_cursor_fetch() in load_table_size(). --- src/gp_activetable.c | 80 +++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/src/gp_activetable.c b/src/gp_activetable.c index 1002dbd1..cf3178b3 100644 --- a/src/gp_activetable.c +++ b/src/gp_activetable.c @@ -936,16 +936,26 @@ get_active_tables_oid(void) static void load_table_size(HTAB *local_table_stats_map) { - int ret; TupleDesc tupdesc; int i; bool found; TableEntryKey key; DiskQuotaActiveTableEntry *quota_entry; + SPIPlanPtr plan; + Portal portal; + char *sql = "select tableid, size, segid from diskquota.table_size"; - ret = SPI_execute("select tableid, size, segid from diskquota.table_size", true, 0); - if (ret != SPI_OK_SELECT) - ereport(ERROR, (errmsg("[diskquota] load_table_size SPI_execute failed: return code %d, error: %m", ret))); + if ((plan = SPI_prepare(sql, 0, NULL)) == NULL) + ereport(ERROR, (errmsg("[diskquota] SPI_prepare(\"%s\") failed", sql))); + if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL) + ereport(ERROR, (errmsg("[diskquota] SPI_cursor_open(\"%s\") failed", sql))); + + SPI_cursor_fetch(portal, true, 10000); + + if (SPI_tuptable == NULL) + { + ereport(ERROR, (errmsg("[diskquota] load_table_size SPI_cursor_fetch failed"))); + } tupdesc = SPI_tuptable->tupdesc; #if GP_VERSION_NUM < 70000 @@ -975,35 +985,43 @@ load_table_size(HTAB *local_table_stats_map) get_database_name(MyDatabaseId)))); } - /* push the table oid and size into local_table_stats_map */ - for (i = 0; i < SPI_processed; i++) + while (SPI_processed > 0) { - HeapTuple tup = SPI_tuptable->vals[i]; - Datum dat; - Oid reloid; - int64 size; - int16 segid; - bool isnull; - - dat = SPI_getbinval(tup, tupdesc, 1, &isnull); - if (isnull) continue; - reloid = DatumGetObjectId(dat); - - dat = SPI_getbinval(tup, tupdesc, 2, &isnull); - if (isnull) continue; - size = DatumGetInt64(dat); - dat = SPI_getbinval(tup, tupdesc, 3, &isnull); - if (isnull) continue; - segid = DatumGetInt16(dat); - key.reloid = reloid; - key.segid = segid; - - quota_entry = (DiskQuotaActiveTableEntry *)hash_search(local_table_stats_map, &key, HASH_ENTER, &found); - quota_entry->reloid = reloid; - quota_entry->tablesize = size; - quota_entry->segid = segid; + /* push the table oid and size into local_table_stats_map */ + for (i = 0; i < SPI_processed; i++) + { + HeapTuple tup = SPI_tuptable->vals[i]; + Datum dat; + Oid reloid; + int64 size; + int16 segid; + bool isnull; + + dat = SPI_getbinval(tup, tupdesc, 1, &isnull); + if (isnull) continue; + reloid = DatumGetObjectId(dat); + + dat = SPI_getbinval(tup, tupdesc, 2, &isnull); + if (isnull) continue; + size = DatumGetInt64(dat); + dat = SPI_getbinval(tup, tupdesc, 3, &isnull); + if (isnull) continue; + segid = DatumGetInt16(dat); + key.reloid = reloid; + key.segid = segid; + + quota_entry = (DiskQuotaActiveTableEntry *)hash_search(local_table_stats_map, &key, HASH_ENTER, &found); + quota_entry->reloid = reloid; + quota_entry->tablesize = size; + quota_entry->segid = segid; + } + SPI_freetuptable(SPI_tuptable); + SPI_cursor_fetch(portal, true, 10000); } - return; + + SPI_freetuptable(SPI_tuptable); + SPI_cursor_close(portal); + SPI_freeplan(plan); } /* From 4a73b1975b745792d2cf048721e643298d4f3449 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Mon, 10 Apr 2023 16:11:05 +0800 Subject: [PATCH 23/31] Split update SQL statement for diskquota.table_size (#325) Fix issue: #318 If the number of entries needed to be updated in diskquota.table_size is too many, the size of StringBuffer will exceed 1GB and raise an error `Cannot enlarge string buffer containing 1073741807 bytes by 20 more bytes.`. We should limit the number of entries in the update statement to 1000000 every time to ensure the string buffer size does not exceed 1GB. --- src/quotamodel.c | 109 ++++++++++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index 8b7a9757..c642759b 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -53,6 +53,8 @@ #define MAX_NUM_KEYS_QUOTA_MAP 8 /* Number of attributes in quota configuration records. */ #define NUM_QUOTA_CONFIG_ATTRS 6 +/* Number of entries for diskquota.table_size update SQL */ +#define SQL_MAX_VALUES_NUMBER 1000000 /* TableSizeEntry macro function */ /* Use the top bit of totalsize as a flush flag. If this bit is set, the size should be flushed into @@ -1122,6 +1124,40 @@ calculate_table_disk_usage(bool is_init, HTAB *local_active_table_stat_map) } } +static void +delete_from_table_size_map(char *str) +{ + StringInfoData delete_statement; + int ret; + + initStringInfo(&delete_statement); + appendStringInfo(&delete_statement, + "WITH deleted_table AS ( VALUES %s ) " + "delete from diskquota.table_size " + "where (tableid, segid) in ( SELECT * FROM deleted_table );", + str); + ret = SPI_execute(delete_statement.data, false, 0); + if (ret != SPI_OK_DELETE) + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("[diskquota] delete_from_table_size_map SPI_execute failed: error code %d", ret))); + pfree(delete_statement.data); +} + +static void +insert_into_table_size_map(char *str) +{ + StringInfoData insert_statement; + int ret; + + initStringInfo(&insert_statement); + appendStringInfo(&insert_statement, "insert into diskquota.table_size values %s;", str); + ret = SPI_execute(insert_statement.data, false, 0); + if (ret != SPI_OK_INSERT) + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("[diskquota] insert_into_table_size_map SPI_execute failed: error code %d", ret))); + pfree(insert_statement.data); +} + /* * Flush the table_size_map to user table diskquota.table_size * To improve update performance, we first delete all the need_to_flush @@ -1135,10 +1171,8 @@ flush_to_table_size(void) TableSizeEntry *tsentry = NULL; StringInfoData delete_statement; StringInfoData insert_statement; - StringInfoData deleted_table_expr; - bool delete_statement_flag = false; - bool insert_statement_flag = false; - int ret; + int delete_entries_num = 0; + int insert_entries_num = 0; /* TODO: Add flush_size_interval to avoid flushing size info in every loop */ @@ -1146,12 +1180,7 @@ flush_to_table_size(void) bool old_optimizer = optimizer; optimizer = false; - initStringInfo(&deleted_table_expr); - appendStringInfo(&deleted_table_expr, "WITH deleted_table AS ( VALUES "); - initStringInfo(&insert_statement); - appendStringInfo(&insert_statement, "insert into diskquota.table_size values "); - initStringInfo(&delete_statement); hash_seq_init(&iter, table_size_map); @@ -1164,17 +1193,39 @@ flush_to_table_size(void) /* delete dropped table from both table_size_map and table table_size */ if (!get_table_size_entry_flag(tsentry, TABLE_EXIST)) { - appendStringInfo(&deleted_table_expr, "(%u,%d), ", tsentry->key.reloid, i); - delete_statement_flag = true; + appendStringInfo(&delete_statement, "%s(%u,%d)", (delete_entries_num == 0) ? " " : ", ", + tsentry->key.reloid, i); + delete_entries_num++; + if (delete_entries_num > SQL_MAX_VALUES_NUMBER) + { + delete_from_table_size_map(delete_statement.data); + resetStringInfo(&delete_statement); + delete_entries_num = 0; + } } /* update the table size by delete+insert in table table_size */ else if (TableSizeEntryGetFlushFlag(tsentry, i)) { - appendStringInfo(&deleted_table_expr, "(%u,%d), ", tsentry->key.reloid, i); - appendStringInfo(&insert_statement, "(%u,%ld,%d), ", tsentry->key.reloid, - TableSizeEntryGetSize(tsentry, i), i); - delete_statement_flag = true; - insert_statement_flag = true; + appendStringInfo(&delete_statement, "%s(%u,%d)", (delete_entries_num == 0) ? " " : ", ", + tsentry->key.reloid, i); + appendStringInfo(&insert_statement, "%s(%u,%ld,%d)", (insert_entries_num == 0) ? " " : ", ", + tsentry->key.reloid, TableSizeEntryGetSize(tsentry, i), i); + delete_entries_num++; + insert_entries_num++; + + if (delete_entries_num > SQL_MAX_VALUES_NUMBER) + { + delete_from_table_size_map(delete_statement.data); + resetStringInfo(&delete_statement); + delete_entries_num = 0; + } + if (insert_entries_num > SQL_MAX_VALUES_NUMBER) + { + insert_into_table_size_map(insert_statement.data); + resetStringInfo(&insert_statement); + insert_entries_num = 0; + } + TableSizeEntryResetFlushFlag(tsentry, i); } } @@ -1184,36 +1235,14 @@ flush_to_table_size(void) pg_atomic_fetch_sub_u32(diskquota_table_size_entry_num, 1); } } - truncateStringInfo(&deleted_table_expr, deleted_table_expr.len - strlen(", ")); - truncateStringInfo(&insert_statement, insert_statement.len - strlen(", ")); - appendStringInfo(&deleted_table_expr, ")"); - appendStringInfo(&insert_statement, ";"); - if (delete_statement_flag) - { - /* concatenate all the need_to_flush table to SQL string */ - appendStringInfoString(&delete_statement, (const char *)deleted_table_expr.data); - appendStringInfoString( - &delete_statement, - "delete from diskquota.table_size where (tableid, segid) in ( SELECT * FROM deleted_table );"); - ret = SPI_execute(delete_statement.data, false, 0); - if (ret != SPI_OK_DELETE) - ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("[diskquota] flush_to_table_size SPI_execute failed: error code %d", ret))); - } - if (insert_statement_flag) - { - ret = SPI_execute(insert_statement.data, false, 0); - if (ret != SPI_OK_INSERT) - ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("[diskquota] flush_to_table_size SPI_execute failed: error code %d", ret))); - } + if (delete_entries_num) delete_from_table_size_map(delete_statement.data); + if (insert_entries_num) insert_into_table_size_map(insert_statement.data); optimizer = old_optimizer; pfree(delete_statement.data); pfree(insert_statement.data); - pfree(deleted_table_expr.data); } /* From 2431a13a298e8066db0b01eae7ac57c6a909d29f Mon Sep 17 00:00:00 2001 From: Anton Kurochkin <45575813+woblerr@users.noreply.github.com> Date: Fri, 14 Apr 2023 05:16:29 +0300 Subject: [PATCH 24/31] Update cmake version in README. (#331) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index baaf2ba8..5be27dd5 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ and their disk usage is isolated between databases. # Development -[cmake](https://cmake.org) (>= 3.18) needs to be installed. +[cmake](https://cmake.org) (>= 3.20) needs to be installed. 1. Build & install disk quota ``` From 51a9038334c155516c475fb17950359c2fa34535 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Mon, 17 Apr 2023 14:25:21 +0800 Subject: [PATCH 25/31] Fix flaky test: test_appendonly (#333) --- tests/regress/expected/test_appendonly.out | 10 ++++++++-- tests/regress/expected7/test_appendonly.out | 10 ++++++++-- tests/regress/sql/test_appendonly.sql | 5 +++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/regress/expected/test_appendonly.out b/tests/regress/expected/test_appendonly.out index d7dfc2ee..010aff75 100644 --- a/tests/regress/expected/test_appendonly.out +++ b/tests/regress/expected/test_appendonly.out @@ -47,14 +47,20 @@ SELECT pg_table_size('t_aoco'); (1 row) -- 2. Test that we are able to perform quota limit on appendonly tables. -SELECT diskquota.set_schema_quota('s_appendonly', '1.2 MB'); +SELECT diskquota.set_schema_quota('s_appendonly', '2 MB'); set_schema_quota ------------------ (1 row) +SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) + -- expect success. -INSERT INTO t_ao SELECT generate_series(1, 10000); +INSERT INTO t_ao SELECT generate_series(1, 100000); SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch --------------------------- diff --git a/tests/regress/expected7/test_appendonly.out b/tests/regress/expected7/test_appendonly.out index c2a61cbb..cfa19a46 100644 --- a/tests/regress/expected7/test_appendonly.out +++ b/tests/regress/expected7/test_appendonly.out @@ -47,14 +47,20 @@ SELECT pg_table_size('t_aoco'); (1 row) -- 2. Test that we are able to perform quota limit on appendonly tables. -SELECT diskquota.set_schema_quota('s_appendonly', '1.2 MB'); +SELECT diskquota.set_schema_quota('s_appendonly', '2 MB'); set_schema_quota ------------------ (1 row) +SELECT diskquota.wait_for_worker_new_epoch(); + wait_for_worker_new_epoch +--------------------------- + t +(1 row) + -- expect success. -INSERT INTO t_ao SELECT generate_series(1, 10000); +INSERT INTO t_ao SELECT generate_series(1, 100000); SELECT diskquota.wait_for_worker_new_epoch(); wait_for_worker_new_epoch --------------------------- diff --git a/tests/regress/sql/test_appendonly.sql b/tests/regress/sql/test_appendonly.sql index 40337eba..c1e996bc 100644 --- a/tests/regress/sql/test_appendonly.sql +++ b/tests/regress/sql/test_appendonly.sql @@ -30,9 +30,10 @@ SELECT tableid::regclass, size SELECT pg_table_size('t_aoco'); -- 2. Test that we are able to perform quota limit on appendonly tables. -SELECT diskquota.set_schema_quota('s_appendonly', '1.2 MB'); +SELECT diskquota.set_schema_quota('s_appendonly', '2 MB'); +SELECT diskquota.wait_for_worker_new_epoch(); -- expect success. -INSERT INTO t_ao SELECT generate_series(1, 10000); +INSERT INTO t_ao SELECT generate_series(1, 100000); SELECT diskquota.wait_for_worker_new_epoch(); From b952190b25c2c5deaf346d87615f83008873a726 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Wed, 26 Apr 2023 11:07:45 +0800 Subject: [PATCH 26/31] Skip refresh_disk_quota_model() when receiving a signal (#321) When with often signals to receive diskquota may call refresh_disk_quota_model more frequently than diskquota_naptime. Solution: when receiving a signal, the time waiting for latch sleep_time will be smaller than diskquota_naptime. We should skip refresh_disk_quota_model() when sleep_time < diskquota_naptime. --- src/diskquota.c | 60 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/src/diskquota.c b/src/diskquota.c index b46f39f3..d5630700 100644 --- a/src/diskquota.c +++ b/src/diskquota.c @@ -485,6 +485,11 @@ disk_quota_worker_main(Datum main_arg) bool is_gang_destroyed = false; TimestampTz log_start_timestamp = GetCurrentTimestamp(); TimestampTz log_end_timestamp; + TimestampTz loop_start_timestamp = 0; + TimestampTz loop_end_timestamp; + long sleep_time = diskquota_naptime * 1000; + long secs; + int usecs; ereport(LOG, (errmsg("[diskquota] disk quota worker process is monitoring database:%s", dbname))); while (!got_sigterm) @@ -504,27 +509,44 @@ disk_quota_worker_main(Datum main_arg) log_start_timestamp = log_end_timestamp; } - SIMPLE_FAULT_INJECTOR("diskquota_worker_main"); - if (!diskquota_is_paused()) - { - /* Refresh quota model with init mode */ - refresh_disk_quota_model(!MyWorkerInfo->dbEntry->inited); - MyWorkerInfo->dbEntry->inited = true; - is_gang_destroyed = false; - } - else if (!is_gang_destroyed) + /* + * If the bgworker receives a signal, the latch will be set ahead of the diskquota.naptime. + * To avoid too frequent diskquota refresh caused by receiving the signal, we use + * loop_start_timestamp and loop_end_timestamp to maintain the elapsed time since the last + * diskquota refresh. If the latch is set ahead of diskquota.naptime, + * refresh_disk_quota_model() should be skipped. + */ + loop_end_timestamp = GetCurrentTimestamp(); + TimestampDifference(loop_start_timestamp, loop_end_timestamp, &secs, &usecs); + sleep_time += secs * 1000 + usecs / 1000; + if (sleep_time >= diskquota_naptime * 1000) { - DisconnectAndDestroyAllGangs(false); - is_gang_destroyed = true; - } - worker_increase_epoch(MyWorkerInfo->dbEntry->dbid); + SIMPLE_FAULT_INJECTOR("diskquota_worker_main"); + if (!diskquota_is_paused()) + { + /* Refresh quota model with init mode */ + refresh_disk_quota_model(!MyWorkerInfo->dbEntry->inited); + MyWorkerInfo->dbEntry->inited = true; + is_gang_destroyed = false; + } + else if (!is_gang_destroyed) + { + DisconnectAndDestroyAllGangs(false); + is_gang_destroyed = true; + } + worker_increase_epoch(MyWorkerInfo->dbEntry->dbid); - // GPDB6 opend a MemoryAccount for us without asking us. - // and GPDB6 did not release the MemoryAccount after SPI finish. - // Reset the MemoryAccount although we never create it. + // GPDB6 opend a MemoryAccount for us without asking us. + // and GPDB6 did not release the MemoryAccount after SPI finish. + // Reset the MemoryAccount although we never create it. #if GP_VERSION_NUM < 70000 - MemoryAccounting_Reset(); + MemoryAccounting_Reset(); #endif /* GP_VERSION_NUM */ + + sleep_time = 0; + } + loop_start_timestamp = GetCurrentTimestamp(); + if (DiskquotaLauncherShmem->isDynamicWorker) { break; @@ -538,7 +560,7 @@ disk_quota_worker_main(Datum main_arg) * background process goes away immediately in an emergency. */ rc = DiskquotaWaitLatch(&MyProc->procLatch, WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH, - diskquota_naptime * 1000L); + diskquota_naptime * 1000 - sleep_time); ResetLatch(&MyProc->procLatch); // be nice to scheduler when naptime == 0 and diskquota_is_paused() == true @@ -563,8 +585,6 @@ disk_quota_worker_main(Datum main_arg) ereport(LOG, (errmsg("[diskquota] stop disk quota worker process to monitor database:%s", dbname))); ereport(DEBUG1, (errmsg("[diskquota] stop disk quota worker process to monitor database:%s", dbname))); #if DISKQUOTA_DEBUG - long secs; - int usecs; TimestampDifference(MyWorkerInfo->dbEntry->last_run_time, GetCurrentTimestamp(), &secs, &usecs); MyWorkerInfo->dbEntry->cost = secs * 1000L + usecs / 1000L; #endif From e589152ffede5452c3dcc50e28d9d2a7dcbb7380 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Wed, 26 Apr 2023 17:12:24 +0800 Subject: [PATCH 27/31] Allocate more shared memory to quota_info (#334) Allocate more SHM to quota_info, so that the user can set more quota configurations. --- src/quotamodel.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/quotamodel.c b/src/quotamodel.c index c642759b..6b8507b3 100644 --- a/src/quotamodel.c +++ b/src/quotamodel.c @@ -55,6 +55,8 @@ #define NUM_QUOTA_CONFIG_ATTRS 6 /* Number of entries for diskquota.table_size update SQL */ #define SQL_MAX_VALUES_NUMBER 1000000 +/* Number of entries for hash table in quota_info */ +#define MAX_QUOTA_MAP_ENTRIES (128 * 1024L) /* TableSizeEntry macro function */ /* Use the top bit of totalsize as a flush flag. If this bit is set, the size should be flushed into @@ -508,7 +510,7 @@ diskquota_worker_shmem_size() Size size; size = hash_estimate_size(MAX_NUM_TABLE_SIZE_ENTRIES / MAX_NUM_MONITORED_DB + 100, sizeof(TableSizeEntry)); size = add_size(size, hash_estimate_size(MAX_LOCAL_DISK_QUOTA_REJECT_ENTRIES, sizeof(LocalRejectMapEntry))); - size = add_size(size, hash_estimate_size(1024L, sizeof(struct QuotaMapEntry)) * NUM_QUOTA_TYPES); + size = add_size(size, hash_estimate_size(MAX_QUOTA_MAP_ENTRIES * NUM_QUOTA_TYPES, sizeof(struct QuotaMapEntry))); return size; } @@ -575,7 +577,8 @@ init_disk_quota_model(uint32 id) memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.entrysize = sizeof(struct QuotaMapEntry); hash_ctl.keysize = sizeof(struct QuotaMapEntryKey); - quota_info[type].map = DiskquotaShmemInitHash(str.data, 1024L, 1024L, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + quota_info[type].map = DiskquotaShmemInitHash(str.data, 1024L, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, HASH_ELEM, + DISKQUOTA_TAG_HASH); } pfree(str.data); } @@ -640,7 +643,8 @@ vacuum_disk_quota_model(uint32 id) memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.entrysize = sizeof(struct QuotaMapEntry); hash_ctl.keysize = sizeof(struct QuotaMapEntryKey); - quota_info[type].map = DiskquotaShmemInitHash(str.data, 1024L, 1024L, &hash_ctl, HASH_ELEM, DISKQUOTA_TAG_HASH); + quota_info[type].map = DiskquotaShmemInitHash(str.data, 1024L, MAX_QUOTA_MAP_ENTRIES, &hash_ctl, HASH_ELEM, + DISKQUOTA_TAG_HASH); hash_seq_init(&iter, quota_info[type].map); while ((qentry = hash_seq_search(&iter)) != NULL) { From f41e75a509adea024298785d220dc96262a51661 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Wed, 26 Apr 2023 19:00:30 +0800 Subject: [PATCH 28/31] Enable stanby test for 6X_STABLE (#335) --- concourse/scripts/test_diskquota.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/concourse/scripts/test_diskquota.sh b/concourse/scripts/test_diskquota.sh index 87c48663..d50ae745 100755 --- a/concourse/scripts/test_diskquota.sh +++ b/concourse/scripts/test_diskquota.sh @@ -27,8 +27,12 @@ function _main() { export SHOW_REGRESS_DIFF=1 time cmake --build . --target installcheck # Run test again with standby master - # activate_standby - # time cmake --build . --target installcheck + # FIXME: enable test for GPDB7 + if [[ $PGPORT -eq 6000 ]] + then + activate_standby + time cmake --build . --target installcheck + fi # Run upgrade test (with standby master) time cmake --build . --target upgradecheck popd From 5e4e123ea8e8ed201ec97263249438476dd37bcd Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Thu, 27 Apr 2023 11:59:58 +0800 Subject: [PATCH 29/31] Bump version to 2.2.1 (#336) --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ccbccc3d..c043eea7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.0 +2.2.1 From 8d2e825dfd2e01fe88d148a731df312d7cec3bd9 Mon Sep 17 00:00:00 2001 From: Chen Mulong Date: Thu, 27 Apr 2023 14:19:04 +0800 Subject: [PATCH 30/31] Use install_gpdb_component in CI test (#337) So the script can be tested as well. --- concourse/scripts/test_diskquota.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/concourse/scripts/test_diskquota.sh b/concourse/scripts/test_diskquota.sh index d50ae745..85b2bce1 100755 --- a/concourse/scripts/test_diskquota.sh +++ b/concourse/scripts/test_diskquota.sh @@ -15,7 +15,12 @@ function activate_standby() { } function _main() { - tar -xzf /home/gpadmin/bin_diskquota/diskquota-*-*.tar.gz -C /usr/local/greenplum-db-devel + local tmp_dir="$(mktemp -d)" + tar -xzf /home/gpadmin/bin_diskquota/diskquota-*-*.tar.gz -C "$tmp_dir" + pushd "$tmp_dir" + ./install_gpdb_component + popd + source /home/gpadmin/gpdb_src/gpAux/gpdemo/gpdemo-env.sh pushd /home/gpadmin/gpdb_src From 50ed2e4e1883ec8ec4e7086b750cb28cdc5a2dc0 Mon Sep 17 00:00:00 2001 From: Vasiliy Ivanov Date: Thu, 4 May 2023 15:32:57 +1000 Subject: [PATCH 31/31] temporary disable upgrade tests until ADBDEV-3649 is not resolved --- CMakeLists.txt | 1 - concourse/scripts/build_diskquota.sh | 3 --- concourse/scripts/test_diskquota.sh | 2 -- 3 files changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38d32e7c..5d44f3e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,6 @@ BuildInfo_Create(${build_info_PATH} # Add installcheck targets add_subdirectory(tests) -add_subdirectory(upgrade_test) # NOTE: keep install part at the end of file, to overwrite previous binary install(PROGRAMS "cmake/install_gpdb_component" DESTINATION ".") diff --git a/concourse/scripts/build_diskquota.sh b/concourse/scripts/build_diskquota.sh index 7b2ee30b..10b66e34 100755 --- a/concourse/scripts/build_diskquota.sh +++ b/concourse/scripts/build_diskquota.sh @@ -11,10 +11,7 @@ function pkg() { export CXX="$(which g++)" pushd /home/gpadmin/diskquota_artifacts - local last_release_path - last_release_path=$(readlink -eq /home/gpadmin/last_released_diskquota_bin/diskquota-*.tar.gz) cmake /home/gpadmin/diskquota_src \ - -DDISKQUOTA_LAST_RELEASE_PATH="${last_release_path}" \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" cmake --build . --target create_artifact popd diff --git a/concourse/scripts/test_diskquota.sh b/concourse/scripts/test_diskquota.sh index 85b2bce1..245196ff 100755 --- a/concourse/scripts/test_diskquota.sh +++ b/concourse/scripts/test_diskquota.sh @@ -38,8 +38,6 @@ function _main() { activate_standby time cmake --build . --target installcheck fi - # Run upgrade test (with standby master) - time cmake --build . --target upgradecheck popd }