ClickHouse/tests/queries/0_stateless/02187_insert_values_with_mv.sql
Azat Khuzhin 155fe2bf9b Fix stress hung because of attached MV with sleep()
In stress tests non-unique databases are used, and in case of non-unique
table names, materialized views may affect other tests, especially if
SELECT from underlying table contains sleep*() like in
02187_insert_values_with_mv, CI report [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/37469/2b513acb2b8d703e737a700a9ccd5f7f323b605f/stress_test__undefined__actions_.html

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-06-07 07:52:06 +03:00

60 lines
1.9 KiB
SQL

CREATE TABLE IF NOT EXISTS data_a_02187 (a Int64) ENGINE=Memory;
CREATE TABLE IF NOT EXISTS data_b_02187 (a Int64) ENGINE=Memory;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv1 TO data_b_02187 AS Select sleepEachRow(0.05) as a FROM data_a_02187;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv2 TO data_b_02187 AS Select sleepEachRow(0.05) as a FROM data_a_02187;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv3 TO data_b_02187 AS Select sleepEachRow(0.05) as a FROM data_a_02187;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv4 TO data_b_02187 AS Select sleepEachRow(0.05) as a FROM data_a_02187;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv5 TO data_b_02187 AS Select sleepEachRow(0.05) as a FROM data_a_02187;
-- INSERT USING VALUES
INSERT INTO data_a_02187 VALUES (1);
-- INSERT USING TABLE
INSERT INTO data_a_02187 SELECT * FROM system.one;
SYSTEM FLUSH LOGS;
SELECT 'VALUES', query_duration_ms >= 250
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING VALUES%'
AND type = 'QueryFinish'
LIMIT 1;
SELECT 'TABLE', query_duration_ms >= 250
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING VALUES%'
AND type = 'QueryFinish'
LIMIT 1;
WITH
(
SELECT initial_query_id
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING VALUES%'
LIMIT 1
) AS q_id
SELECT 'VALUES', view_duration_ms >= 50
FROM system.query_views_log
WHERE initial_query_id = q_id;
WITH
(
SELECT initial_query_id
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING TABLE%'
LIMIT 1
) AS q_id
SELECT 'TABLE', view_duration_ms >= 50
FROM system.query_views_log
WHERE initial_query_id = q_id;