This repository was archived by the owner on Jan 14, 2026. It is now read-only.
forked from greenplum-db/diskquota-archive
-
Notifications
You must be signed in to change notification settings - Fork 4
ADBDEV-3685 Error handling for disqkuota worker startup stage #20
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,46 @@ | ||
| -- | ||
| -- Tests for error handling when the worker catches the error during | ||
| -- its first run. | ||
| -- | ||
|
|
||
| -- Function checking whether worker on given db is up | ||
| CREATE or REPLACE LANGUAGE plpython2u; | ||
| CREATE | ||
| CREATE or REPLACE FUNCTION check_worker_presence(dbname text, wait_time int) RETURNS boolean AS $$ import psutil import time worker_name = 'bgworker: [diskquota] ' + dbname time.sleep(wait_time) for proc in psutil.process_iter(): try: if 'postgres' in proc.name().lower(): for val in proc.cmdline(): if worker_name in val: return True except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): pass return False $$ LANGUAGE plpython2u EXECUTE ON MASTER; | ||
| CREATE | ||
|
|
||
| -- Test diskquota behavior when an error occurs during the worker's first run. | ||
| -- The error leads to process termination. And launcher won't start it again | ||
| -- until extension reload or SIGHUP signal. | ||
| CREATE EXTENSION diskquota; | ||
| CREATE | ||
| SELECT check_worker_presence(current_database(), 0); | ||
| check_worker_presence | ||
| ----------------------- | ||
| t | ||
| (1 row) | ||
| SELECT gp_inject_fault('diskquota_worker_initialization', 'error', dbid) FROM gp_segment_configuration WHERE role='p' AND content=-1; | ||
| gp_inject_fault | ||
| ----------------- | ||
| Success: | ||
| (1 row) | ||
| SELECT diskquota.init_table_size_table(); | ||
| init_table_size_table | ||
| ----------------------- | ||
|
|
||
| (1 row) | ||
| SELECT check_worker_presence(current_database(), current_setting('diskquota.worker_timeout')::int / 2); | ||
| check_worker_presence | ||
| ----------------------- | ||
| f | ||
| (1 row) | ||
| -- Reload configuration and check that worker is up again | ||
| !\retcode gpstop -u; | ||
| (exited with code 0) | ||
| SELECT check_worker_presence(current_database(), current_setting('diskquota.worker_timeout')::int / 2); | ||
| check_worker_presence | ||
| ----------------------- | ||
| t | ||
| (1 row) | ||
| DROP EXTENSION diskquota; | ||
| DROP |
This file contains hidden or 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 hidden or 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,40 @@ | ||
| -- | ||
| -- Tests for error handling when the worker catches the error during | ||
| -- its first run. | ||
| -- | ||
|
|
||
| -- Function checking whether worker on given db is up | ||
| CREATE or REPLACE LANGUAGE plpython2u; | ||
| CREATE or REPLACE FUNCTION check_worker_presence(dbname text, wait_time int) | ||
| RETURNS boolean | ||
| AS $$ | ||
| import psutil | ||
| import time | ||
| worker_name = 'bgworker: [diskquota] ' + dbname | ||
| time.sleep(wait_time) | ||
| for proc in psutil.process_iter(): | ||
| try: | ||
| if 'postgres' in proc.name().lower(): | ||
| for val in proc.cmdline(): | ||
| if worker_name in val: | ||
| return True | ||
| except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): | ||
| pass | ||
| return False | ||
| $$ LANGUAGE plpython2u EXECUTE ON MASTER; | ||
|
|
||
| -- Test diskquota behavior when an error occurs during the worker's first run. | ||
| -- The error leads to process termination. And launcher won't start it again | ||
| -- until extension reload or SIGHUP signal. | ||
|
RekGRpth marked this conversation as resolved.
|
||
| CREATE EXTENSION diskquota; | ||
| SELECT check_worker_presence(current_database(), 0); | ||
| SELECT gp_inject_fault('diskquota_worker_initialization', 'error', dbid) | ||
| FROM gp_segment_configuration WHERE role='p' AND content=-1; | ||
| SELECT diskquota.init_table_size_table(); | ||
| SELECT check_worker_presence(current_database(), | ||
| current_setting('diskquota.worker_timeout')::int / 2); | ||
|
RekGRpth marked this conversation as resolved.
|
||
| -- Reload configuration and check that worker is up again | ||
| !\retcode gpstop -u; | ||
| SELECT check_worker_presence(current_database(), | ||
| current_setting('diskquota.worker_timeout')::int / 2); | ||
| DROP EXTENSION diskquota; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.