未验证 提交 92ffdcb7 编写于 作者: N Ning Yu 提交者: GitHub

resgroup: load resgroup settings even for bypassed queries.

`SHOW memory_spill_ratio` will always display 20 when it's the first
query in a connection (if you run this query in psql and pressed TAB
when entering the command then the implicit queries ran by the tab
completion function will be the first), the root cause is that SHOW
command will be bypassed in resgroup, so the bound resgroup will not be
assigned, and the resgroup's settings will not be loaded.

To display the proper value in this case we will also load the resgroup
settings even for bypassed queries.
上级 94c30fdb
......@@ -2347,7 +2347,31 @@ AssignResGroupOnMaster(void)
* resource group, leave self unassigned
*/
if (shouldBypassQuery(debug_query_string))
{
ResGroupCaps caps;
/*
* Although we decide to bypass this query we should load the
* memory_spill_ratio setting from the resgroup, otherwise a
* `SHOW memory_spill_ratio` command will output the default value 20
* if it's the first query in the connection (make sure tab completion
* is not triggered otherwise it will run some implicit query before
* you execute the SHOW command).
*/
do {
decideResGroup(&groupInfo);
/*
* It's possible that the resgroup is concurrently dropped,
* so we need to check again in such a case.
*/
if (groupInfo.group)
caps = groupInfo.group->caps;
} while (!groupInfo.group || groupInfo.group->groupId == InvalidOid);
groupSetMemorySpillRatio(&caps);
return;
}
PG_TRY();
{
......
-- This query must be the first one in this case.
-- SHOW command will be bypassed in resgroup, when it's the first command
-- in a connection it needs special handling to show memory_spill_ratio
-- correctly. Verify that it shows the correct value 10 instead of default 20.
SHOW memory_spill_ratio;
memory_spill_ratio
------------------
10
(1 row)
--start_ignore
DROP ROLE role1_spill_test;
ERROR: role "role1_spill_test" does not exist
......
......@@ -83,7 +83,7 @@ SELECT * FROM gp_toolkit.gp_resgroup_config;
groupid|groupname |concurrency|proposed_concurrency|cpu_rate_limit|memory_limit|proposed_memory_limit|memory_shared_quota|proposed_memory_shared_quota|memory_spill_ratio|proposed_memory_spill_ratio|memory_auditor|cpuset
-------+-------------+-----------+--------------------+--------------+------------+---------------------+-------------------+----------------------------+------------------+---------------------------+--------------+------
6437 |default_group|20 |20 |30 |30 |30 |50 |50 |20 |20 |vmtracker |-1
6438 |admin_group |2 |2 |10 |10 |10 |50 |50 |20 |20 |vmtracker |-1
6438 |admin_group |2 |2 |10 |10 |10 |50 |50 |10 |10 |vmtracker |-1
(2 rows)
-- negative
......
......@@ -36,3 +36,6 @@ SELECT * FROM gp_toolkit.gp_resq_priority_backend;
-- by default admin_group has concurrency set to -1 which leads to
-- very small memory quota for each resgroup slot, correct it.
ALTER RESOURCE GROUP admin_group SET concurrency 2;
-- in later cases we will SHOW memory_spill_ratio as first command
-- to verify that it can be correctly loaded even for bypassed commands
ALTER RESOURCE GROUP admin_group SET memory_spill_ratio 10;
......@@ -73,3 +73,7 @@ rqpsession|rqpcommand|rqppriority|rqpweight
-- very small memory quota for each resgroup slot, correct it.
ALTER RESOURCE GROUP admin_group SET concurrency 2;
ALTER
-- in later cases we will SHOW memory_spill_ratio as first command
-- to verify that it can be correctly loaded even for bypassed commands
ALTER RESOURCE GROUP admin_group SET memory_spill_ratio 10;
ALTER
-- This query must be the first one in this case.
-- SHOW command will be bypassed in resgroup, when it's the first command
-- in a connection it needs special handling to show memory_spill_ratio
-- correctly. Verify that it shows the correct value 10 instead of default 20.
SHOW memory_spill_ratio;
--start_ignore
DROP ROLE role1_spill_test;
DROP ROLE role2_spill_test;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册