Test for checking time limit in index analysis

This commit is contained in:
Alexander Gololobov 2024-09-16 13:34:40 +02:00
parent 4af369fbc4
commit f5b9d5ad34
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,4 @@
5
03176_q1 1 0 0
03176_q2 1 2 0
03176_q3 0 1 1

View File

@ -0,0 +1,32 @@
-- Tags: no-parallel, no-tsan, no-asan, no-ubsan, no-msan, no-debug, no-fasttest
-- no-parallel because the test uses failpoint
CREATE TABLE t_03176(k UInt64, v UInt64) ENGINE=MergeTree() ORDER BY k PARTITION BY k;
INSERT INTO t_03176 SELECT number, number FROM numbers(5);
-- Table is partitioned by k to so it will have 5 partitions
SELECT count() FROM system.parts WHERE database = currentDatabase() AND table = 't_03176' AND active;
-- This query is fast without failpoint: should take < 1 sec
EXPLAIN indexes = 1 SELECT * FROM t_03176 ORDER BY k LIMIT 5 SETTINGS log_comment = '03176_q1' FORMAT Null;
SYSTEM ENABLE FAILPOINT slowdown_index_analysis;
-- Check that failpont actually works: the query should take >= 5 sec
EXPLAIN indexes = 1 SELECT * FROM t_03176 ORDER BY k LIMIT 5 SETTINGS log_comment = '03176_q2' FORMAT Null;
-- Now the query should be cancelled after about 1 sec
EXPLAIN indexes = 1 SELECT * FROM t_03176 ORDER BY k LIMIT 5 SETTINGS log_comment = '03176_q3', max_execution_time = 1.1 FORMAT Null; -- { serverError TIMEOUT_EXCEEDED }
SYSTEM DISABLE FAILPOINT slowdown_index_analysis;
SYSTEM FLUSH LOGS;
-- Check that q1 was fast, q2 was slow and q3 had timeout
SELECT log_comment, type = 'QueryFinish', intDiv(query_duration_ms, 2000), length(exception) > 0
FROM system.query_log
WHERE current_database = currentDatabase() AND log_comment LIKE '03176_q_' AND type IN ('QueryFinish', 'ExceptionBeforeStart')
ORDER BY log_comment;
DROP TABLE t_03176;