-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-39495 Parallel Query: Use temporary work tables to ship results: basic test #5176
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
2
commits into
main
Choose a base branch
from
13.0-MDEV-39495
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.
+2,026
−19
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,84 @@ | ||
| SET DEBUG_SYNC='RESET'; | ||
| # | ||
| # MDEV-39492 Parallel Query: Study how to create worker threads | ||
| # | ||
| create table t1 select seq from seq_1_to_2; | ||
| set session parallel_worker_threads=3; | ||
| # we should currently see 3 warnings; | ||
| select SQL_BUFFER_RESULT seq from t1; | ||
| seq | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| set session parallel_worker_threads=10; | ||
| select SQL_BUFFER_RESULT seq from t1; | ||
| seq | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 1 | ||
| 2 | ||
| 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 SQL_BUFFER_RESULT seq from t1;; | ||
| # now use the default connection to view/kill the thread group executing | ||
| # the parallel work | ||
| connection default; | ||
| SET DEBUG_SYNC='now WAIT_FOR pwt_worker_paused'; | ||
| # wait for all 3 workers to hit our debug sync point | ||
| # then have a look at what is in our process list without thread ID | ||
| select USER, DB, STATE, SUBSTRING(INFO, 1, 32) | ||
| from information_schema.processlist | ||
| where (INFO regexp '.*parallel worker.*' or | ||
| STATE regexp '.*parallel worker.*') and | ||
| NOT INFO regexp '.*information_schema\.processlist.*'; | ||
| USER DB STATE SUBSTRING(INFO, 1, 32) | ||
| root test debug sync point: now Parallel Worker 3 For Thread ID | ||
| root test debug sync point: now Parallel Worker 2 For Thread ID | ||
| root test debug sync point: now Parallel Worker 1 For Thread ID | ||
| root test Reading data from parallel workers select SQL_BUFFER_RESULT seq fro | ||
| kill query ID; | ||
| # signal our workers to continue execution | ||
| SET DEBUG_SYNC = "now SIGNAL pwt_worker_continue"; | ||
| # then wait for the manager thread to clean up and go back to sleep | ||
| # review error message on --reap | ||
| connection killee; | ||
| ERROR 70100: Query execution was interrupted | ||
| SET DEBUG_SYNC = "RESET"; | ||
| # save as above, but kill a worker with a simple kill and see the | ||
| # connection drop | ||
| select SQL_BUFFER_RESULT seq from t1;; | ||
| 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; | ||
| drop table t1; | ||
| 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,108 @@ | ||
| # | ||
| # 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 # | ||
|
|
||
| create table t1 select seq from seq_1_to_2; | ||
|
|
||
| set session parallel_worker_threads=3; | ||
| --echo # we should currently see 3 warnings; | ||
| select SQL_BUFFER_RESULT seq from t1; | ||
|
|
||
| set session parallel_worker_threads=10; | ||
| select SQL_BUFFER_RESULT seq from t1; | ||
|
|
||
| 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, we are using a debug_sync_set_action | ||
| # to pause execution in our worker threads just after they have done something | ||
|
|
||
| SET @save_dbug= @@global.debug_dbug; | ||
| SET GLOBAL debug_dbug = "+d,pwt_worker_pause_before_signal"; | ||
|
|
||
| --send select SQL_BUFFER_RESULT seq from t1; | ||
| --echo # now use the default connection to view/kill the thread group executing | ||
| --echo # the parallel work | ||
| --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 # wait for all 3 workers to hit our debug sync point | ||
| let $wait_condition= | ||
| select count(*) = 3 from information_schema.processlist | ||
| where state like 'debug sync%' and info like '%Thread ID $id'; | ||
| --source include/wait_condition.inc | ||
| --echo # then have a look at what is in our process list without thread ID | ||
| select USER, DB, STATE, SUBSTRING(INFO, 1, 32) | ||
| from information_schema.processlist | ||
| where (INFO regexp '.*parallel worker.*' or | ||
| STATE regexp '.*parallel worker.*') and | ||
| NOT INFO regexp '.*information_schema\.processlist.*'; | ||
| --replace_result $killID ID | ||
| eval kill query $killID; | ||
| --echo # signal our workers to continue execution | ||
| SET DEBUG_SYNC = "now SIGNAL pwt_worker_continue"; | ||
| --echo # then wait for the manager thread to clean up and go back to sleep | ||
| let $wait_condition= | ||
| select count(*) = 1 from information_schema.processlist | ||
| where command = 'Sleep' and id = $id; | ||
| --source include/wait_condition.inc | ||
| #select * from information_schema.processlist; | ||
| --echo # review error message on --reap | ||
| --connection killee | ||
| --error ER_QUERY_INTERRUPTED | ||
| 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 SQL_BUFFER_RESULT seq from t1; | ||
| 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; | ||
|
|
||
| drop table t1; | ||
| 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,54 @@ | ||
| SET @save_optimizer_trace= @@optimizer_trace; | ||
| SET optimizer_trace='enabled=on'; | ||
| CREATE TABLE t_plain (a INT); | ||
| INSERT INTO t_plain VALUES (1),(2),(3); | ||
| CREATE TABLE t_blob (a INT, b BLOB); | ||
| INSERT INTO t_blob VALUES (1,'x'),(2,'y'),(3,'z'); | ||
| CREATE TABLE t_text (a INT, b TEXT); | ||
| INSERT INTO t_text VALUES (1,'x'),(2,'y'),(3,'z'); | ||
| CREATE TABLE t_m1 (a INT) ENGINE=MyISAM; | ||
| INSERT INTO t_m1 VALUES (1),(2),(3); | ||
| CREATE TABLE t_m2 (a INT) ENGINE=MyISAM; | ||
| INSERT INTO t_m2 VALUES (4),(5),(6); | ||
| CREATE TABLE t_merge (a INT) ENGINE=MERGE UNION=(t_m1,t_m2) INSERT_METHOD=LAST; | ||
| CREATE TABLE t_ft (a INT, b VARCHAR(64), FULLTEXT(b)) ENGINE=MyISAM; | ||
| INSERT INTO t_ft VALUES (1,'alpha beta'),(2,'gamma delta'),(3,'epsilon zeta'); | ||
| set session parallel_worker_threads=2; | ||
| # plain table: chosen for parallel scan (expect 1) | ||
| SELECT a FROM t_plain; | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
| chosen_for_parallel_scan | ||
| 1 | ||
| # BLOB column present: excluded, not chosen (expect 0) | ||
| SELECT a FROM t_blob; | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
| chosen_for_parallel_scan | ||
| 0 | ||
| # TEXT column present: excluded, not chosen (expect 0) | ||
| SELECT a FROM t_text; | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
| chosen_for_parallel_scan | ||
| 0 | ||
| # MERGE engine: excluded, not chosen (expect 0) | ||
| SELECT a FROM t_merge; | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
| chosen_for_parallel_scan | ||
| 0 | ||
| # fulltext-searched (MATCH in select list): excluded, not chosen (expect 0) | ||
| SELECT a, MATCH(b) AGAINST('alpha') FROM t_ft; | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
| chosen_for_parallel_scan | ||
| 0 | ||
| DROP TABLE t_plain, t_blob, t_text, t_merge, t_m1, t_m2, t_ft; | ||
| SET optimizer_trace= @save_optimizer_trace; | ||
| 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,80 @@ | ||
| # | ||
| # MDEV-39492 Parallel Query: tables that cannot be shipped row-by-row through a | ||
| # worker batch table are excluded from parallel worker scan. | ||
| # | ||
| # JOIN::choose_parallel_scan() records the table picked for the parallel scan | ||
| # in the optimizer trace as "chosen_for_parallel_scan". An ordinary table is | ||
| # chosen; a table is rejected by the use_parallel_scan gate when it has a | ||
| # BLOB/TEXT (blob-backed) column, uses the MERGE engine, or is fulltext-searched | ||
| # (a MATCH ... AGAINST refers to it). We assert presence/absence of that trace | ||
| # key (1/0) rather than the temporary row-multiplication behaviour. | ||
| # | ||
| --source include/not_embedded.inc | ||
|
|
||
| SET @save_optimizer_trace= @@optimizer_trace; | ||
| SET optimizer_trace='enabled=on'; | ||
|
|
||
| CREATE TABLE t_plain (a INT); | ||
| INSERT INTO t_plain VALUES (1),(2),(3); | ||
| CREATE TABLE t_blob (a INT, b BLOB); | ||
| INSERT INTO t_blob VALUES (1,'x'),(2,'y'),(3,'z'); | ||
| CREATE TABLE t_text (a INT, b TEXT); | ||
| INSERT INTO t_text VALUES (1,'x'),(2,'y'),(3,'z'); | ||
|
|
||
| # MERGE table over two MyISAM children | ||
| CREATE TABLE t_m1 (a INT) ENGINE=MyISAM; | ||
| INSERT INTO t_m1 VALUES (1),(2),(3); | ||
| CREATE TABLE t_m2 (a INT) ENGINE=MyISAM; | ||
| INSERT INTO t_m2 VALUES (4),(5),(6); | ||
| CREATE TABLE t_merge (a INT) ENGINE=MERGE UNION=(t_m1,t_m2) INSERT_METHOD=LAST; | ||
|
|
||
| # fulltext: MATCH in the select list keeps a full table scan and marks the | ||
| # table fulltext-searched | ||
| CREATE TABLE t_ft (a INT, b VARCHAR(64), FULLTEXT(b)) ENGINE=MyISAM; | ||
| INSERT INTO t_ft VALUES (1,'alpha beta'),(2,'gamma delta'),(3,'epsilon zeta'); | ||
|
|
||
| set session parallel_worker_threads=2; | ||
|
|
||
| --echo # plain table: chosen for parallel scan (expect 1) | ||
| --disable_result_log | ||
| SELECT a FROM t_plain; | ||
| --enable_result_log | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
|
|
||
| --echo # BLOB column present: excluded, not chosen (expect 0) | ||
| --disable_result_log | ||
| SELECT a FROM t_blob; | ||
| --enable_result_log | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
|
|
||
| --echo # TEXT column present: excluded, not chosen (expect 0) | ||
| --disable_result_log | ||
| SELECT a FROM t_text; | ||
| --enable_result_log | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
|
|
||
| --echo # MERGE engine: excluded, not chosen (expect 0) | ||
| --disable_result_log | ||
| SELECT a FROM t_merge; | ||
| --enable_result_log | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
|
|
||
| --echo # fulltext-searched (MATCH in select list): excluded, not chosen (expect 0) | ||
| --disable_result_log | ||
| SELECT a, MATCH(b) AGAINST('alpha') FROM t_ft; | ||
| --enable_result_log | ||
| SELECT JSON_EXTRACT(trace, '$**.chosen_for_parallel_scan') IS NOT NULL | ||
| AS chosen_for_parallel_scan | ||
| FROM information_schema.optimizer_trace; | ||
|
|
||
| DROP TABLE t_plain, t_blob, t_text, t_merge, t_m1, t_m2, t_ft; | ||
| SET optimizer_trace= @save_optimizer_trace; | ||
| set session parallel_worker_threads=default; |
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
__apple_build_version__is specific to Apple's Clang compiler. If MariaDB is compiled on macOS using a different compiler (such as GCC or upstream Clang), this macro will not be defined, and the build will fall back to the defaultMAX_THREAD_NAME 16instead of usingMAXTHREADNAMESIZE(which is 64). Using the standard platform macro__APPLE__is more robust.