-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-39597: Remove save/restore of proc_info in free_tmp_table #5097
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # | ||
| # MDEV-39597: SHOW PROFILE reports duplicate sending data | ||
| # stage for INSERT...SELECT due to save/restore in free_tmp_table | ||
| # | ||
| CREATE TABLE profile_test ( | ||
| id INT PRIMARY KEY AUTO_INCREMENT, | ||
| name VARCHAR(100), | ||
| value INT | ||
| ); | ||
| INSERT INTO profile_test (name, value) VALUES | ||
| ('alpha',1),('beta',2),('gamma',3),('delta',4),('epsilon',5), | ||
| ('zeta',6),('eta',7),('theta',8),('iota',9),('kappa',10); | ||
| SET profiling = 1; | ||
| INSERT INTO profile_test (name, value) | ||
| SELECT name, value FROM profile_test LIMIT 5; | ||
| # Check that no stage appears twice consecutivley around removing tmp table | ||
| SELECT COUNT(*) AS duplicate_stage_found | ||
| FROM ( | ||
| SELECT | ||
| STATE, | ||
| LAG(STATE) OVER (ORDER BY SEQ) AS prev_status, | ||
| LEAD(STATE) OVER (ORDER BY SEQ) AS next_status | ||
| FROM information_schema.profiling | ||
| WHERE QUERY_ID = 1 | ||
| ) t | ||
| WHERE STATE = 'Removing tmp table' | ||
| AND prev_status = next_status; | ||
| duplicate_stage_found | ||
| 0 | ||
| SET profiling = 0; | ||
| DROP TABLE profile_test; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --echo # | ||
| --echo # MDEV-39597: SHOW PROFILE reports duplicate sending data | ||
| --echo # stage for INSERT...SELECT due to save/restore in free_tmp_table | ||
| --echo # | ||
|
|
||
| --source include/have_profiling.inc | ||
| --disable_ps2_protocol | ||
|
|
||
| CREATE TABLE profile_test ( | ||
| id INT PRIMARY KEY AUTO_INCREMENT, | ||
| name VARCHAR(100), | ||
| value INT | ||
| ); | ||
| INSERT INTO profile_test (name, value) VALUES | ||
| ('alpha',1),('beta',2),('gamma',3),('delta',4),('epsilon',5), | ||
| ('zeta',6),('eta',7),('theta',8),('iota',9),('kappa',10); | ||
| SET profiling = 1; | ||
| INSERT INTO profile_test (name, value) | ||
| SELECT name, value FROM profile_test LIMIT 5; | ||
|
|
||
| --echo # Check that no stage appears twice consecutivley around removing tmp table | ||
|
|
||
| SELECT COUNT(*) AS duplicate_stage_found | ||
| FROM ( | ||
| SELECT | ||
| STATE, | ||
| LAG(STATE) OVER (ORDER BY SEQ) AS prev_status, | ||
| LEAD(STATE) OVER (ORDER BY SEQ) AS next_status | ||
| FROM information_schema.profiling | ||
| WHERE QUERY_ID = 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoding
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. QUERY_ID = 1 is intentional. SET profiling = 1 is not profiled, so the INSERT...SELECT is always query 1 in a fresh session. Using MAX(QUERY_ID) would be fragile here as subsequent queries in the test would become the MAX. |
||
| ) t | ||
| WHERE STATE = 'Removing tmp table' | ||
| AND prev_status = next_status; | ||
|
|
||
| --enable_ps2_protocol | ||
|
|
||
| # clean up | ||
| SET profiling = 0; | ||
| DROP TABLE profile_test; | ||
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.
I do not get the effect described using the queries in the test neither in 10.11 nor in 13.1. In 13.1 I get:
And in 10.11 I get:
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.
Thank you for the review.
On reproducing the issue:
The profile output shown has only 4 stages "Starting", "Freeing items", "Updating status", "Reset for next command", which is consistent with a simple statement, not an INSERT...SELECT. An INSERT...SELECT would show stages including "Opening tables", "Creating tmp table", "Sending data". It appears the INSERT...SELECT from the test setup was not run before querying information_schema.profiling.
To reproduce, please run the full sequence in a fresh session:
SET profiling = 1is not itself profiled, so theINSERT...SELECTbecomesQUERY_ID = 1.The table creation and data insertion are setup steps required to trigger the tmp table code path, without them the duplicate will not appear.
On the test:
The test was confirmed to fail on unpatched code and pass with the fix applied locally. The trailing newline has been added.
On the lowest affected version:
The same save/restore pattern exists in 10.11. I will confirm the bug reproduces there and rebase accordingly once we confirm the reproduce steps work for you.
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.
my bad: I missed the INSERT part when trying. It does indeed fail when not patched.