-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-39492 Parallel Query: Study how to create worker threads #5099
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
Open
mariadb-RexJohnston
wants to merge
1
commit into
main
Choose a base branch
from
13.0-MDEV-39492-2
base: main
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| SET DEBUG_SYNC='RESET'; | ||
| # | ||
| # MDEV-39492 Parallel Query: Study how to create worker threads | ||
| # | ||
| set session parallel_worker_threads=3; | ||
| # we should currently see 3 warnings; | ||
| select seq from seq_1_to_2; | ||
| seq | ||
| 1 | ||
| 2 | ||
| Warnings: | ||
| Warning 1105 This is an example warning to show we can push a warning from a worker thread to its manager | ||
| Warning 1105 This is an example warning to show we can push a warning from a worker thread to its manager | ||
| Warning 1105 This is an example warning to show we can push a warning from a worker thread to its manager | ||
| set session parallel_worker_threads=10; | ||
| # the 10th workers throws out an error | ||
| select seq from seq_1_to_2; | ||
| ERROR HY000: Argument to the worker_busted_function() function does not belong to the range [0,1] | ||
| set session parallel_worker_threads=0; | ||
| connect killee, localhost, root, , ; | ||
| # check that kill query on a parallel worker is passed to the manager | ||
| connection killee; | ||
| set session parallel_worker_threads=3; | ||
| SET @save_dbug= @@global.debug_dbug; | ||
| SET GLOBAL debug_dbug = "+d,pwt_worker_pause_before_signal"; | ||
| select seq from seq_1_to_2;; | ||
| connection default; | ||
| SET DEBUG_SYNC='now WAIT_FOR pwt_worker_paused'; | ||
| # Process list without thread ID | ||
| select USER, HOST, DB, COMMAND, STATE, SUBSTRING(INFO, 1, 32) | ||
| from information_schema.processlist; | ||
| USER HOST DB COMMAND STATE SUBSTRING(INFO, 1, 32) | ||
| root localhost test Query debug sync point: now Parallel Worker 3 For Thread ID | ||
| root localhost test Query debug sync point: now Parallel Worker 2 For Thread ID | ||
| root localhost test Query debug sync point: now Parallel Worker 1 For Thread ID | ||
| root localhost test Query Reading data from parallel workers select seq from seq_1_to_2 | ||
| root localhost test Query Filling schema table select USER, HOST, DB, COMMAND, | ||
| kill query ID; | ||
| SET DEBUG_SYNC = "now SIGNAL pwt_worker_continue"; | ||
| connection killee; | ||
| Got one of the listed errors | ||
| SET DEBUG_SYNC = "RESET"; | ||
| # save as above, but kill a worker with a simple kill and see the | ||
| # connection drop | ||
| select seq from seq_1_to_2;; | ||
| connection default; | ||
| SET DEBUG_SYNC='now WAIT_FOR pwt_worker_paused'; | ||
| kill ID; | ||
| SET DEBUG_SYNC = "now SIGNAL pwt_worker_continue"; | ||
| connection killee; | ||
| ERROR 70100: Query execution was interrupted | ||
| # killee connection now dead, confirmed below | ||
| connection default; | ||
| SET GLOBAL debug_dbug = @save_dbug; | ||
| SET DEBUG_SYNC = "RESET"; |
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,90 @@ | ||
| # | ||
| # Test KILL and KILL QUERY statements. | ||
| # | ||
|
|
||
| -- source include/count_sessions.inc | ||
| -- source include/not_embedded.inc | ||
| # this will be used in the future -- source include/have_innodb.inc | ||
| -- source include/have_sequence.inc | ||
| --source include/have_debug.inc | ||
| --source include/have_debug_sync.inc | ||
| SET DEBUG_SYNC='RESET'; | ||
|
|
||
| --disable_service_connection | ||
|
|
||
| --echo # | ||
| --echo # MDEV-39492 Parallel Query: Study how to create worker threads | ||
| --echo # | ||
|
|
||
| set session parallel_worker_threads=3; | ||
| --echo # we should currently see 3 warnings; | ||
| select seq from seq_1_to_2; | ||
|
|
||
| set session parallel_worker_threads=10; | ||
| --echo # the 10th workers throws out an error | ||
| --error ER_ARGUMENT_OUT_OF_RANGE | ||
| select seq from seq_1_to_2; | ||
|
|
||
| set session parallel_worker_threads=0; | ||
| connect (killee, localhost, root, , ); | ||
|
|
||
| --echo # check that kill query on a parallel worker is passed to the manager | ||
|
|
||
| connection killee; | ||
| let $id= `select connection_id()`; | ||
| set session parallel_worker_threads=3; | ||
| # worker THDs don't inherit session vars, so flip dbug globally | ||
| SET @save_dbug= @@global.debug_dbug; | ||
| SET GLOBAL debug_dbug = "+d,pwt_worker_pause_before_signal"; | ||
|
|
||
| --send select seq from seq_1_to_2; | ||
| connection default; | ||
| SET DEBUG_SYNC='now WAIT_FOR pwt_worker_paused'; | ||
| let $name= "Parallel Worker 1 For Thread ID $id"; | ||
| let $killID= `SELECT @kid:=ID from information_schema.processlist | ||
| where info like $name limit 1`; | ||
| --echo # Process list without thread ID | ||
| select USER, HOST, DB, COMMAND, STATE, SUBSTRING(INFO, 1, 32) | ||
| from information_schema.processlist; | ||
| --replace_result $killID ID | ||
| eval kill query $killID; | ||
| SET DEBUG_SYNC = "now SIGNAL pwt_worker_continue"; | ||
| let $wait_condition= | ||
| select count(*) = 1 from information_schema.processlist | ||
| where command = 'Sleep' and id = $id; | ||
| --source include/wait_condition.inc | ||
| connection killee; | ||
| --error ER_QUERY_INTERRUPTED, ER_ARGUMENT_OUT_OF_RANGE | ||
| --reap | ||
|
|
||
| SET DEBUG_SYNC = "RESET"; | ||
|
|
||
| --echo # save as above, but kill a worker with a simple kill and see the | ||
| --echo # connection drop | ||
|
|
||
| --send select seq from seq_1_to_2; | ||
| connection default; | ||
| SET DEBUG_SYNC='now WAIT_FOR pwt_worker_paused'; | ||
| let $name= "Parallel Worker 1 For Thread ID $id"; | ||
| let $killID= `SELECT @kid:=ID from information_schema.processlist | ||
| where info like $name limit 1`; | ||
| --replace_result $killID ID | ||
| eval kill $killID; | ||
| SET DEBUG_SYNC = "now SIGNAL pwt_worker_continue"; | ||
| let $wait_condition= | ||
| select count(*) = 0 from information_schema.processlist | ||
| where command = 'Sleep' and id = $id; | ||
| --source include/wait_condition.inc | ||
| connection killee; | ||
| --disable_warnings | ||
| --error ER_QUERY_INTERRUPTED | ||
| --reap | ||
|
|
||
| --echo # killee connection now dead, confirmed below | ||
|
|
||
| connection default; | ||
|
|
||
| SET GLOBAL debug_dbug = @save_dbug; | ||
| SET DEBUG_SYNC = "RESET"; | ||
|
|
||
| --source include/wait_until_count_sessions.inc |
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,21 @@ | ||
| # | ||
| # MDEV-39492 Parallel Query: OOM in worker error_to_queue surfaces a | ||
| # single ER_OUTOFMEMORY warning so worker diagnostics aren't silently | ||
| # lost. | ||
| # | ||
| set @save_dbug=@@global.debug_dbug; | ||
| set global debug_dbug="+d,pwt_error_to_queue_oom"; | ||
| set session parallel_worker_threads=1; | ||
| # The prototype worker emits either a warning or my_error() depending on the | ||
| # parity of its thread id. Either path runs through error_to_queue; the | ||
| # DBUG injection forces both into the OOM branch, so neither the original | ||
| # warning nor the original error reaches the user. We expect just the | ||
| # manager-surfaced ER_OUTOFMEMORY warning. | ||
| select count(*) from seq_1_to_2; | ||
| count(*) | ||
| 2 | ||
| show warnings; | ||
| Level Code Message | ||
| Warning 1037 Parallel worker diagnostics were dropped due to memory allocation failure | ||
| set global debug_dbug=@save_dbug; | ||
| set session parallel_worker_threads=default; |
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,33 @@ | ||
| # | ||
| # Test OOM handling in the parallel worker error/warning queue. | ||
| # | ||
|
|
||
| -- source include/count_sessions.inc | ||
| -- source include/not_embedded.inc | ||
| -- source include/have_sequence.inc | ||
| -- source include/have_debug.inc | ||
|
|
||
| --disable_service_connection | ||
|
|
||
| --echo # | ||
| --echo # MDEV-39492 Parallel Query: OOM in worker error_to_queue surfaces a | ||
| --echo # single ER_OUTOFMEMORY warning so worker diagnostics aren't silently | ||
| --echo # lost. | ||
| --echo # | ||
|
|
||
| set @save_dbug=@@global.debug_dbug; | ||
| set global debug_dbug="+d,pwt_error_to_queue_oom"; | ||
| set session parallel_worker_threads=1; | ||
|
|
||
| --echo # The prototype worker emits either a warning or my_error() depending on the | ||
| --echo # parity of its thread id. Either path runs through error_to_queue; the | ||
| --echo # DBUG injection forces both into the OOM branch, so neither the original | ||
| --echo # warning nor the original error reaches the user. We expect just the | ||
| --echo # manager-surfaced ER_OUTOFMEMORY warning. | ||
| select count(*) from seq_1_to_2; | ||
| show warnings; | ||
|
|
||
| set global debug_dbug=@save_dbug; | ||
| set session parallel_worker_threads=default; | ||
|
|
||
| --source include/wait_until_count_sessions.inc |
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
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
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.
The macro name
MAX_THREAD_NAMEis quite generic and could potentially conflict with definitions in system headers or other libraries. It is recommended to use a more specific prefix, such asMY_MAX_THREAD_NAMEorMARIADB_MAX_THREAD_NAME.