forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADBDEV-6156 Count startup memory of each process when using resource groups #1023
Open
dnskvlnk
wants to merge
18
commits into
adb-6.x-dev
Choose a base branch
from
ADBDEV-6156
base: adb-6.x-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
635f0da
Count startup memory of each process when using resource groups
f075158
Try to fix diff caused by gpstop
f8bd708
Merge branch 'adb-6.x-dev' into ADBDEV-6156
da24513
Use the actual number of startup chunks instaed of a heardcoded value
c1acd81
Merge branch 'adb-6.x-dev' into ADBDEV-6156
fb14e74
Add resGroupPallocIgnoreStartup which copies old Add resGroupPalloc
cdf357a
Add new test case which tests redzone
ec269c9
Ignore generated file
8c71e1c
Ignore function creation output
4579e61
Add a comment for resGroupPallocIgnoreStartup
ef84cdb
Consider startup memory only if allocation was successful
cf1b560
Bring out allocation logic to a dedicated function
562ac84
Reword comments so they would be more clear
94328c9
Merge branch 'adb-6.x-dev' into ADBDEV-6156
73582b3
Remove redundant test
4a9360e
Make resGroupPallocImpl static
475f3cb
Fix library path for test output
ef3a7e5
Merge branch 'adb-6.x-dev' into ADBDEV-6156
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/test/isolation2/input/resgroup/resgroup_startup_memory.source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
-- start_ignore | ||
! gpconfig -c runaway_detector_activation_percent -v 100; | ||
! gpstop -rai; | ||
|
||
CREATE OR REPLACE FUNCTION resGroupPalloc(float) RETURNS int AS | ||
'@abs_builddir@/../regress/regress@DLSUFFIX@', 'resGroupPalloc' | ||
LANGUAGE C READS SQL DATA; | ||
-- end_ignore | ||
|
||
ALTER RESOURCE GROUP default_group SET memory_limit 10; | ||
ALTER RESOURCE GROUP admin_group SET memory_limit 30; | ||
|
||
CREATE RESOURCE GROUP test_group with (concurrency=1, memory_limit=59, memory_spill_ratio=100, cpu_rate_limit=20); | ||
CREATE ROLE test_role RESOURCE GROUP test_group; | ||
CREATE ROLE default_role RESOURCE GROUP default_group; | ||
|
||
-- 1. Occupy all memory on a segment and fail with vmem tracker error | ||
ALTER RESOURCE GROUP admin_group SET concurrency 1; | ||
ALTER RESOURCE GROUP default_group SET concurrency 1; | ||
|
||
-- Start a session which will be detached from a group when the query is done | ||
-- resource groups can't see startup chunks occupied by a detached session but | ||
-- the vmem tracker can | ||
0: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid != (SELECT pg_backend_pid()); | ||
0: CREATE TABLE test (a int); | ||
|
||
-- Now we need to occupy all memory in all resgroups | ||
1: SET ROLE test_role; | ||
1: BEGIN; | ||
1: SELECT resGroupPalloc(1.0) FROM gp_dist_random('gp_id') WHERE gp_segment_id = 1; | ||
|
||
2: SET ROLE default_role; | ||
2: BEGIN; | ||
2: SELECT resGroupPalloc(1.0) FROM gp_dist_random('gp_id') WHERE gp_segment_id = 1; | ||
|
||
-- The sum of all resource groups' memory is 99% and 1% is global shared memory aka | ||
-- freeChunks. On this test cluster each segment has 682mb of memory, so 1% is ~7mb. | ||
-- The minimum number of startup chunks a process can have is 8mb. | ||
3: BEGIN; | ||
3: SELECT resGroupPalloc(1.0) FROM gp_dist_random('gp_id') WHERE gp_segment_id = 1; | ||
|
||
1q: | ||
2q: | ||
3q: | ||
|
||
-- start_ignore | ||
! gpconfig -c runaway_detector_activation_percent -v 20; | ||
! gpstop -rai; | ||
|
||
5: CREATE OR REPLACE FUNCTION resGroupPallocIgnoreStartup(float) RETURNS int AS | ||
'@abs_builddir@/../regress/regress@DLSUFFIX@', 'resGroupPallocIgnoreStartup' | ||
LANGUAGE C READS SQL DATA; | ||
-- end_ignore | ||
|
||
5: drop role test_role; | ||
5: drop resource group test_group; | ||
5: alter resource group default_group set memory_limit 20; | ||
5: alter resource group admin_group set memory_limit 10; | ||
5: alter resource group admin_group set concurrency 1; | ||
5: select * from gp_toolkit.gp_resgroup_config; | ||
5q: | ||
|
||
-- This query will be killed by redzone because resGroupPallocIgnoreStartup just allocates | ||
-- the memory size of all resgroup memory. Before the patch, a group had no memory tracked | ||
bandetto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-- at the moment we called resGroupPalloc, so this case shows that now a group tracks startup memory. | ||
5: SELECT resGroupPallocIgnoreStartup(2.39) FROM gp_dist_random('gp_id') WHERE gp_segment_id = 1; | ||
5q: | ||
|
||
-- This won't fail because now resGroupPalloc subtracts startup chunks from the requested amount | ||
-- of memory to keep all previews tests intact. Leaving resGroupPalloc without changes may break them. | ||
5: SELECT resGroupPalloc(2.39) FROM gp_dist_random('gp_id') WHERE gp_segment_id = 1; | ||
5q: | ||
|
||
5: DROP TABLE test; | ||
5: DROP ROLE default_role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and below
Do we really want to kill ALL backends except the current one?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the point of the test, I don't want other processes to interfere. I can change it if you explain what problems it can cause