Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59836 from ClickHouse/backport/23.8/59662
Backport #59662 to 23.8: Fix query start time on non initial queries
- Loading branch information
Showing
5 changed files
with
42 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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
8 changes: 0 additions & 8 deletions
8
...queries/0_stateless/02590_interserver_mode_client_info_initial_query_start_time.reference
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
tests/queries/0_stateless/02590_interserver_mode_client_info_initial_query_start_time.sh
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
tests/queries/0_stateless/02985_shard_query_start_time.reference
This file contains 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,2 @@ | ||
QueryStart 2 2 2 2 | ||
QueryFinish 2 2 2 2 |
34 changes: 34 additions & 0 deletions
34
tests/queries/0_stateless/02985_shard_query_start_time.sql
This file contains 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,34 @@ | ||
DROP TABLE IF EXISTS sharded_table; | ||
CREATE TABLE sharded_table (dummy UInt8) ENGINE = Distributed('test_cluster_two_shards', 'system', 'one'); | ||
|
||
SET prefer_localhost_replica=0; | ||
SELECT * FROM sharded_table FORMAT Null SETTINGS log_comment='02985_shard_query_start_time_query_1'; | ||
|
||
SYSTEM FLUSH LOGS; | ||
|
||
-- Check that there are 2 queries to shards and for each one query_start_time_microseconds is more recent | ||
-- than initial_query_start_time_microseconds, and initial_query_start_time_microseconds matches the original query | ||
-- query_start_time_microseconds | ||
WITH | ||
( | ||
SELECT | ||
(query_id, query_start_time, query_start_time_microseconds) | ||
FROM | ||
system.query_log | ||
WHERE | ||
event_date >= yesterday() | ||
AND current_database = currentDatabase() | ||
AND log_comment = '02985_shard_query_start_time_query_1' | ||
AND type = 'QueryFinish' | ||
) AS id_and_start_tuple | ||
SELECT | ||
type, | ||
countIf(query_start_time >= initial_query_start_time), -- Using >= because it's comparing seconds | ||
countIf(query_start_time_microseconds > initial_query_start_time_microseconds), | ||
countIf(initial_query_start_time = id_and_start_tuple.2), | ||
countIf(initial_query_start_time_microseconds = id_and_start_tuple.3) | ||
FROM | ||
system.query_log | ||
WHERE | ||
NOT is_initial_query AND initial_query_id = id_and_start_tuple.1 | ||
GROUP BY type; |