This is an automated email from the ASF dual-hosted git repository. maxyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 996d0e40c6a957f887ca0a4d82520a2de4b8697c Author: RMT <[email protected]> AuthorDate: Tue Feb 27 15:57:19 2024 +0800 Fix no response when alter io_limit of resource group to '-1' (#17095) Fix no response when alter io_limit of resource group to '-1'. There is no action when ALTER RESOURCE GROUP xxx SET IO_LIMIT '-1' before. Now the action is that clear the content of io.max and update relation pg_resgroupcapability. --- src/backend/commands/resgroupcmds.c | 11 ++++++++++- src/backend/utils/resgroup/resgroup.c | 12 +++++++----- .../resgroup/resgroup_auxiliary_tools_v2.out | 6 ++++++ .../input/resgroup/resgroup_io_limit.source | 10 ++++++++++ .../output/resgroup/resgroup_io_limit.source | 21 +++++++++++++++++++++ .../sql/resgroup/resgroup_auxiliary_tools_v2.sql | 13 +++++++++++++ 6 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/backend/commands/resgroupcmds.c b/src/backend/commands/resgroupcmds.c index 6ebe1ac243e..9be40eba69f 100644 --- a/src/backend/commands/resgroupcmds.c +++ b/src/backend/commands/resgroupcmds.c @@ -486,7 +486,6 @@ AlterResourceGroup(AlterResourceGroupStmt *stmt) validateCapabilities(pg_resgroupcapability_rel, groupid, &caps, false); AssertImply(limitType != RESGROUP_LIMIT_TYPE_IO_LIMIT, caps.io_limit == NIL); - AssertImply(limitType == RESGROUP_LIMIT_TYPE_IO_LIMIT, caps.io_limit != NIL); /* cpuset & cpu_max_percent can not coexist. * if cpuset is active, then cpu_max_percent must set to CPU_RATE_LIMIT_DISABLED, @@ -519,6 +518,16 @@ AlterResourceGroup(AlterResourceGroupStmt *stmt) updateResgroupCapabilityEntry(pg_resgroupcapability_rel, groupid, RESGROUP_LIMIT_TYPE_IO_LIMIT, 0, cgroupOpsRoutine->dumpio(caps.io_limit)); + else + { + /* + * When alter io_limit to -1 , the caps.io_limit will be nil. + * So we should update the io_limit in capability relation to -1. + */ + updateResgroupCapabilityEntry(pg_resgroupcapability_rel, + groupid, RESGROUP_LIMIT_TYPE_IO_LIMIT, + 0, DefaultIOLimit); + } } else { diff --git a/src/backend/utils/resgroup/resgroup.c b/src/backend/utils/resgroup/resgroup.c index 4a6c9c14b94..72f1ac75d41 100644 --- a/src/backend/utils/resgroup/resgroup.c +++ b/src/backend/utils/resgroup/resgroup.c @@ -807,11 +807,13 @@ ResGroupAlterOnCommit(const ResourceGroupCallbackContext *callbackCtx) } else if (callbackCtx->limittype == RESGROUP_LIMIT_TYPE_IO_LIMIT) { - if (callbackCtx->caps.io_limit != NIL) - { - cgroupOpsRoutine->cleario(callbackCtx->groupid); - cgroupOpsRoutine->setio(callbackCtx->groupid, callbackCtx->caps.io_limit); - } + /* + * When alter io_limit to -1 , the caps.io_limit will be nil. + * There are no errors in io_limit string when caps.io_limit is nil. + * When alter io_limit, caps.io_limit is nil means this resource group's io_limit should be clear. + */ + cgroupOpsRoutine->cleario(callbackCtx->groupid); + cgroupOpsRoutine->setio(callbackCtx->groupid, callbackCtx->caps.io_limit); } /* reset default group if cpuset has changed */ diff --git a/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out b/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out index bc5e8764091..de159f4910e 100644 --- a/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out +++ b/src/test/isolation2/expected/resgroup/resgroup_auxiliary_tools_v2.out @@ -157,3 +157,9 @@ clear_io_max(groupid) cgroup_path = "/sys/fs/cgroup/gpdb/%d/io.max" % groupid return os.stat(cgroup_path).st_size == 0 $$ LANGUAGE plpython3u; CREATE + +0: CREATE OR REPLACE FUNCTION check_io_max_empty(groupname text) RETURNS BOOL AS $$ import os +# get group oid sql = "select groupid from gp_toolkit.gp_resgroup_config where groupname = '%s'" % groupname result = plpy.execute(sql) groupid = result[0]['groupid'] +cgroup_path = "/sys/fs/cgroup/gpdb/%d/io.max" % groupid +return os.stat(cgroup_path).st_size == 0 $$ LANGUAGE plpython3u; +CREATE diff --git a/src/test/isolation2/input/resgroup/resgroup_io_limit.source b/src/test/isolation2/input/resgroup/resgroup_io_limit.source index a09414f3f99..9a5fe2dc2f7 100644 --- a/src/test/isolation2/input/resgroup/resgroup_io_limit.source +++ b/src/test/isolation2/input/resgroup/resgroup_io_limit.source @@ -69,6 +69,15 @@ SELECT groupid, groupname, cpuset FROM gp_toolkit.gp_resgroup_config WHERE group SELECT gp_inject_fault('create_resource_group_fail', 'reset', 1); +-- clear limitations +CREATE RESOURCE GROUP rg_test_group7 WITH (concurrency=10, cpu_max_percent=10, io_limit='rg_io_limit_ts_1:rbps=1000,wbps=1000'); + +SELECT check_cgroup_io_max('rg_test_group7', 'rg_io_limit_ts_1', 'rbps=1048576000 wbps=1048576000 riops=max wiops=max'); + +ALTER RESOURCE GROUP rg_test_group7 SET IO_LIMIT '-1'; + +SELECT check_io_max_empty('rg_test_group7'); + -- view -- start_ignore SELECT * from gp_toolkit.gp_resgroup_iostats_per_host; @@ -82,6 +91,7 @@ DROP RESOURCE GROUP rg_test_group2; DROP RESOURCE GROUP rg_test_group3; DROP RESOURCE GROUP rg_test_group4; DROP RESOURCE GROUP rg_test_group5; +DROP RESOURCE GROUP rg_test_group7; DROP TABLESPACE rg_io_limit_ts_1; diff --git a/src/test/isolation2/output/resgroup/resgroup_io_limit.source b/src/test/isolation2/output/resgroup/resgroup_io_limit.source index 3e7bd7f2134..ea7957bc1cf 100644 --- a/src/test/isolation2/output/resgroup/resgroup_io_limit.source +++ b/src/test/isolation2/output/resgroup/resgroup_io_limit.source @@ -137,6 +137,25 @@ SELECT gp_inject_fault('create_resource_group_fail', 'reset', 1); Success: (1 row) +-- clear limitations +CREATE RESOURCE GROUP rg_test_group7 WITH (concurrency=10, cpu_max_percent=10, io_limit='rg_io_limit_ts_1:rbps=1000,wbps=1000'); +CREATE + +SELECT check_cgroup_io_max('rg_test_group7', 'rg_io_limit_ts_1', 'rbps=1048576000 wbps=1048576000 riops=max wiops=max'); + check_cgroup_io_max +--------------------- + t +(1 row) + +ALTER RESOURCE GROUP rg_test_group7 SET IO_LIMIT '-1'; +ALTER + +SELECT check_io_max_empty('rg_test_group7'); + check_io_max_empty +-------------------- + t +(1 row) + -- view -- start_ignore SELECT * from gp_toolkit.gp_resgroup_iostats_per_host; @@ -167,6 +186,8 @@ DROP RESOURCE GROUP rg_test_group4; DROP DROP RESOURCE GROUP rg_test_group5; DROP +DROP RESOURCE GROUP rg_test_group7; +DROP DROP TABLESPACE rg_io_limit_ts_1; DROP diff --git a/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql b/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql index b762850468c..e274acbb8f3 100644 --- a/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql +++ b/src/test/isolation2/sql/resgroup/resgroup_auxiliary_tools_v2.sql @@ -373,3 +373,16 @@ $$ LANGUAGE plpython3u; return os.stat(cgroup_path).st_size == 0 $$ LANGUAGE plpython3u; + +0: CREATE OR REPLACE FUNCTION check_io_max_empty(groupname text) RETURNS BOOL AS $$ + import os + + # get group oid + sql = "select groupid from gp_toolkit.gp_resgroup_config where groupname = '%s'" % groupname + result = plpy.execute(sql) + groupid = result[0]['groupid'] + + cgroup_path = "/sys/fs/cgroup/gpdb/%d/io.max" % groupid + + return os.stat(cgroup_path).st_size == 0 +$$ LANGUAGE plpython3u; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
