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/CMakeLists.txt b/CMakeLists.txt index 361b3cbf..5d44f3e4 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) @@ -64,32 +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--1.0.3--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}) @@ -171,12 +150,6 @@ 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() # NOTE: keep install part at the end of file, to overwrite previous binary install(PROGRAMS "cmake/install_gpdb_component" DESTINATION ".") @@ -184,7 +157,7 @@ install(FILES ${diskquota_DDL} DESTINATION "share/postgresql/extension/") install(TARGETS diskquota DESTINATION "lib/postgresql/") install(FILES ${build_info_PATH} DESTINATION ".") -file(GLOB sql_files RELATIVE ${CMAKE_SOURCE_DIR} diskquota--2.*.sql) +file(GLOB sql_files RELATIVE ${DISKQUOTA_DDL_DIR} "${DISKQUOTA_DDL_DIR}/diskquota--2.*.sql") list(FILTER sql_files EXCLUDE REGEX ".*--.*--.*") list(FILTER sql_files EXCLUDE REGEX ".*diskquota--${DISKQUOTA_MAJOR_VERSION}.${DISKQUOTA_MINOR_VERSION}.*") foreach(so IN LISTS sql_files) 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 ``` diff --git a/VERSION b/VERSION index ccbccc3d..c043eea7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.0 +2.2.1 diff --git a/cmake/Regress.cmake b/cmake/Regress.cmake index 6d91c760..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 ...] @@ -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 @@ -24,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} @@ -43,17 +51,64 @@ 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} ) 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) + execute_process( + COMMAND + grep gp_inject_fault ${f} + OUTPUT_QUIET + RESULT_VARIABLE ret) + if(ret EQUAL 0) + 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 ${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" - "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 @@ -82,8 +137,25 @@ function(RegressTarget_Add name) endif() 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) + if (arg_EXCLUDE_FAULT_INJECT_TEST AND (r IN_LIST fault_injector_test_list)) + continue() + endif() set(regress_arg ${regress_arg} ${r}) endforeach() @@ -99,17 +171,23 @@ 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() - 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) @@ -131,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/concourse/pipeline/job_def.lib.yml b/concourse/pipeline/job_def.lib.yml index 130e89e3..c206ca6e 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 @@ -66,8 +66,8 @@ 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_diskquota_bin: bin_diskquota_gpdb7_rhel8 +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 os: rhel8 @@ -228,12 +228,10 @@ 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) -#@ end - put: #@ conf["res_intermediates_bin"] params: file: diskquota_artifacts/diskquota.tar.gz diff --git a/concourse/pipeline/res_def.yml b/concourse/pipeline/res_def.yml index 54d05adf..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 @@ -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 -- name: bin_gpdb7_rhel8 + 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_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\.((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.*-el8.tar.gz # Diskquota releases - name: bin_diskquota_gpdb6_rhel6 diff --git a/concourse/scripts/build_diskquota.sh b/concourse/scripts/build_diskquota.sh index 3ca3efbc..10b66e34 100755 --- a/concourse/scripts/build_diskquota.sh +++ b/concourse/scripts/build_diskquota.sh @@ -11,11 +11,8 @@ function pkg() { export CXX="$(which g++)" pushd /home/gpadmin/diskquota_artifacts - local last_release_path - # last_release_path=$(readlink -e /home/gpadmin/last_released_diskquota_bin/diskquota-*.tar.gz) cmake /home/gpadmin/diskquota_src \ -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..245196ff 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 @@ -27,10 +32,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 - # Run upgrade test (with standby master) - # time cmake --build . --target upgradecheck + # FIXME: enable test for GPDB7 + if [[ $PGPORT -eq 6000 ]] + then + activate_standby + time cmake --build . --target installcheck + fi 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/diskquota--1.0--1.0.3.sql b/control/ddl/diskquota--1.0--1.0.3.sql similarity index 100% rename from diskquota--1.0--1.0.3.sql rename to control/ddl/diskquota--1.0--1.0.3.sql 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.3--2.0.sql b/control/ddl/diskquota--1.0.3--2.0.sql similarity index 100% rename from diskquota--1.0.3--2.0.sql rename to control/ddl/diskquota--1.0.3--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 94% rename from diskquota.c rename to src/diskquota.c index 4581a29e..d5630700 100644 --- a/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, @@ -320,10 +321,12 @@ define_guc_variables(void) void disk_quota_worker_main(Datum main_arg) { - char *dbname = MyBgworkerEntry->bgw_name; + char dbname[NAMEDATALEN]; - MyProcPort = (Port *)calloc(1, sizeof(Port)); - MyProcPort->database_name = dbname; /* To show the database in the log */ + MyWorkerInfo = (DiskQuotaWorkerEntry *)DatumGetPointer(MyBgworkerEntry->bgw_main_arg); + Assert(MyWorkerInfo != NULL); + + memcpy(dbname, MyWorkerInfo->dbname.data, NAMEDATALEN); /* Disable ORCA to avoid fallback */ optimizer = false; @@ -334,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))); /* @@ -480,32 +481,72 @@ 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; + 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) { int rc; - SIMPLE_FAULT_INJECTOR("diskquota_worker_main"); - if (!diskquota_is_paused()) + /* + * 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)) { - /* Refresh quota model with init mode */ - refresh_disk_quota_model(!MyWorkerInfo->dbEntry->inited); - MyWorkerInfo->dbEntry->inited = true; - is_gang_destroyed = false; + ereport(LOG, (errmsg("[diskquota] disk quota worker process is monitoring database:%s", dbname))); + log_start_timestamp = log_end_timestamp; } - 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; @@ -519,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 @@ -544,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 @@ -909,7 +948,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 +957,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 +1273,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 +1292,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 +1319,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))); } } @@ -1367,7 +1404,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/diskquota.h b/src/diskquota.h similarity index 97% rename from diskquota.h rename to src/diskquota.h index a52037cf..f044773b 100644 --- a/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 }; @@ -265,7 +266,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_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 99% rename from diskquota_utility.c rename to src/diskquota_utility.c index 6e55ee3c..f406809c 100644 --- a/diskquota_utility.c +++ b/src/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; } @@ -1440,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; @@ -1448,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/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 93% rename from gp_activetable.c rename to src/gp_activetable.c index 73732e67..cf3178b3 100644 --- a/gp_activetable.c +++ b/src/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,15 +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) + + 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); - relation_close(rel, NoLock); } /* @@ -425,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()) { @@ -805,7 +817,15 @@ get_active_tables_oid(void) rnode.spcNode = active_table_file_entry->tablespaceoid; relOid = get_relid_by_relfilenode(rnode); - if (relOid != InvalidOid) + /* 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 { prelid = get_primary_table_oid(relOid, true); active_table_entry = hash_search(local_active_table_stats_map, &prelid, HASH_ENTER, &found); @@ -916,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"; + + 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))); - 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))); + 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 @@ -955,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); } /* 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 96% rename from quotamodel.c rename to src/quotamodel.c index 8b7a9757..6b8507b3 100644 --- a/quotamodel.c +++ b/src/quotamodel.c @@ -53,6 +53,10 @@ #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 +/* 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 @@ -506,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; } @@ -573,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); } @@ -638,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) { @@ -1122,6 +1128,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 +1175,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 +1184,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 +1197,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 +1239,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); } /* diff --git a/relation_cache.c b/src/relation_cache.c similarity index 97% rename from relation_cache.c rename to src/relation_cache.c index 224a9c37..647779de 100644 --- a/relation_cache.c +++ b/src/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,7 +162,7 @@ update_relation_entry(Oid relid, DiskQuotaRelationCacheEntry *relation_entry, Di relation_entry->primary_table_relid = relid; - relation_close(rel, NoLock); + RelationClose(rel); } void @@ -224,18 +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); - relation_close(rel, NoLock); + + RelationClose(rel); } parsed_oid = diskquota_parse_primary_table_oid(namespace, relname); @@ -323,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()) { 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 dbe3aabf..895d7f9f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,18 +1,34 @@ 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) +# 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 ${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} + SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/regress/diskquota_schedule + EXCLUDE_FAULT_INJECT_TEST ${exclude_fault_injector} REGRESS_OPTS --load-extension=gp_inject_fault --dbname=contrib_regression) @@ -23,19 +39,20 @@ 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} + SCHEDULE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/isolation2/isolation2_schedule + EXCLUDE_FAULT_INJECT_TEST ${exclude_fault_injector} REGRESS_OPTS --load-extension=gp_inject_fault --dbname=isolation2test) 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) diff --git a/tests/init_file b/tests/init_file index 477b1355..613ebf85 100644 --- a/tests/init_file +++ b/tests/init_file @@ -9,6 +9,9 @@ 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"/ +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 @@ -18,6 +21,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_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/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/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/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 index 5f01eee9..bf842f49 100644 --- a/tests/isolation2/expected7/test_postmaster_restart.out +++ b/tests/isolation2/expected7/test_postmaster_restart.out @@ -27,21 +27,29 @@ SET -- 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) +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 -2774491 +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 -2774659 +674189 -- end_ignore (exited with code 0) @@ -51,15 +59,22 @@ ERROR: schema's disk space quota exceeded with name: 157893 (seg0 127.0.0.1:60 -- 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 1) +(exited with code 0) -- bgworker should be terminated !\retcode pgrep -f "[p]ostgres.*diskquota.*isolation2test"; -- start_ignore @@ -70,13 +85,13 @@ server stopped -- 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 pg_ctl -D $MASTER_DATA_DIRECTORY -w -o "-c gp_role=dispatch" 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, +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 @@ -92,14 +107,22 @@ server started -- launcher should be restarted !\retcode pgrep -f "[p]ostgres.*launcher"; -- start_ignore -2771049 +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 -2771074 +675239 -- end_ignore (exited with code 0) @@ -113,7 +136,7 @@ SET (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) +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 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 d176b404..00000000 --- a/tests/isolation2/expected7/test_truncate.out +++ /dev/null @@ -1,79 +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; --- 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 47eb944d..00000000 --- a/tests/isolation2/expected7/test_vacuum.out +++ /dev/null @@ -1,92 +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; --- 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_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/isolation2_schedule7 b/tests/isolation2/isolation2_schedule7 deleted file mode 100644 index 56792ee6..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_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/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; 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/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) 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/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_appendonly.out b/tests/regress/expected/test_appendonly.out index d0c465af..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 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, 1000); +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/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_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/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_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/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/expected/test_rejectmap_mul_db.out b/tests/regress/expected/test_rejectmap_mul_db.out index 40c43ae3..8ac4193c 100644 --- a/tests/regress/expected/test_rejectmap_mul_db.out +++ b/tests/regress/expected/test_rejectmap_mul_db.out @@ -22,8 +22,8 @@ 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. +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 ------- 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/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_appendonly.out b/tests/regress/expected7/test_appendonly.out index d324bd76..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 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, 1000); +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_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 ed2edc8d..00000000 --- a/tests/regress/expected7/test_rejectmap_mul_db.out +++ /dev/null @@ -1,92 +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: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) - --- 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) - -SELECT diskquota.pause(); - pause -------- - -(1 row) - ---\c tjmu1 --- The rejectmap should contain entris with dbnode = 0 and dbnode = tjmu1_oid and tjmu2_oid. count = 2 --- The entries for tjmu1 should not be cleared -SELECT COUNT(DISTINCT r.dbnode) FROM (SELECT (diskquota.show_rejectmap()).* FROM gp_dist_random('gp_id')) as r where r.dbnode != 0; - count -------- - 2 -(1 row) - --- start_ignore -\! gpconfig -c "diskquota.hard_limit" -v "off" > /dev/null -\! 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 diff --git a/tests/regress/sql/test_appendonly.sql b/tests/regress/sql/test_appendonly.sql index 88529347..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 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, 1000); +INSERT INTO t_ao SELECT generate_series(1, 100000); SELECT diskquota.wait_for_worker_new_epoch(); 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 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); 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; diff --git a/tests/regress/sql/test_rejectmap_mul_db.sql b/tests/regress/sql/test_rejectmap_mul_db.sql index 3b2fd734..e59647f3 100644 --- a/tests/regress/sql/test_rejectmap_mul_db.sql +++ b/tests/regress/sql/test_rejectmap_mul_db.sql @@ -16,7 +16,7 @@ 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. +-- 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; 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 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_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.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_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.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_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, + 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+\)/