-
Notifications
You must be signed in to change notification settings - Fork 752
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
MySQL Handler Kill Query #5448
MySQL Handler Kill Query #5448
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
a675b5a
to
c571dd1
Compare
query/src/sessions/session.rs
Outdated
@@ -63,16 +65,38 @@ impl Session { | |||
let session_settings = Settings::try_create(&conf)?; | |||
let ref_count = Arc::new(AtomicUsize::new(0)); | |||
let status = Arc::new(Default::default()); | |||
match typ { | |||
SessionType::MySQL => { | |||
let mysql_conn_id = session_mgr |
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.
It's incorrect, we must save the mysql_conn_id in fetch_add
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.
saved in there: self.mysql_basic_conn_id.fetch_add(1, Ordering::Relaxed);
Maybe we can directly use session_mgr.mysql_basic_conn_id?
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.
Must save the return value of fetch_add
, see https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU32.html#method.fetch_add
Otherwise, you can't ensure the load value is not changed.
c571dd1
to
da493c2
Compare
Maybe we can add a test with |
da493c2
to
b9e58a9
Compare
Like this tests/suites/1_stateful/02_query/02_0000_kill_query.py? |
b9e58a9
to
cfd36f2
Compare
time.sleep(5) | ||
mycursor.execute("SELECT * FROM system.processes WHERE extra_info like '%select * from numbers(999999999)%' and extra_info not like '%system.processes%'") | ||
res = mycursor.fetchone() | ||
assert res is None |
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.
result file is empty, the test will be skipped.
cfd36f2
to
53ff418
Compare
2139a16
to
a1c4afe
Compare
|
a1c4afe
to
354b261
Compare
Link to discussion: databendlabs#5405
354b261
to
c7b0b05
Compare
From my test on local, the server(MySQL handler) received the kill query from the client, but databend-query select cannot be canceled:
|
Actually this pr just do one thing : convert mysql_conn_id to session_id. I do this test: in session 1 select sum(number) from numbers(10000000000); in session 2 root@mysqldb 21:15:57 [(none)]> show processlist;
+--------------------------------------+-------+-----------------+------+-------+----------+----------------------------------------------+--------------+------------------------+-------------------------+-------------------------+--------------------------+---------------------+
| id | type | host | user | state | database | extra_info | memory_usage | dal_metrics_read_bytes | dal_metrics_write_bytes | scan_progress_read_rows | scan_progress_read_bytes | mysql_connection_id |
+--------------------------------------+-------+-----------------+------+-------+----------+----------------------------------------------+--------------+------------------------+-------------------------+-------------------------+--------------------------+---------------------+
| 6297888a-668f-4e20-a7ce-adc8fadbed85 | MySQL | 127.0.0.1:51820 | root | Query | default | select sum(number) from numbers(10000000000) | 0 | 0 | 0 | 124320000 | 994560000 | 28 |
| 0f92fe22-0015-47ac-85c5-5463a94f9cbe | MySQL | 127.0.0.1:51814 | root | Query | default | show processlist | 0 | 0 | 0 | 0 | 0 | 25 |
| 3ac8bcbf-6a13-4859-b276-7f81570fb871 | MySQL | 127.0.0.1:51802 | root | Idle | default | NULL | 0 | NULL | NULL | NULL | NULL | 20 |
+--------------------------------------+-------+-----------------+------+-------+----------+----------------------------------------------+--------------+------------------------+-------------------------+-------------------------+--------------------------+---------------------+
3 rows in set (0.10 sec)
Read 3 rows, 631.00 B in 0.052 sec., 57.85 rows/sec., 11.88 KiB/sec.
root@mysqldb 21:16:26 [(none)]> kill query '6297888a-668f-4e20-a7ce-adc8fadbed85';
Query OK, 0 rows affected (0.07 sec)
Read 0 rows, 0.00 B in 0.003 sec., 0 rows/sec., 0.00 B/sec.
And then the session 1 's query looks like not exit, but if already exit.
|
maybe you could off the new processor.
I met a similar situation, but I haven't submitted the issue yet. |
And I find if let the query in session 1 execute a long time, and kill it in session 2 the session 1 will at aborting state. |
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
MySQL Client support according to "Ctrl C" interrupt a long query.
Link to discussion: #5405
Changelog
Related Issues
Fixes #4871