mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #65604 from pamarcos/03172_error_log_table_not_empty
Fix 03172_error_log_table_not_empty
This commit is contained in:
commit
b28202d7e5
41
tests/queries/0_stateless/03172_error_log_table_not_empty.sh
Executable file
41
tests/queries/0_stateless/03172_error_log_table_not_empty.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
# Get the previous number of errors for 111, 222 and 333
|
||||
errors_111=$($CLICKHOUSE_CLIENT -q "SELECT sum(value) FROM system.error_log WHERE code = 111")
|
||||
errors_222=$($CLICKHOUSE_CLIENT -q "SELECT sum(value) FROM system.error_log WHERE code = 222")
|
||||
errors_333=$($CLICKHOUSE_CLIENT -q "SELECT sum(value) FROM system.error_log WHERE code = 333")
|
||||
|
||||
# Throw three random errors: 111, 222 and 333 and wait for more than collect_interval_milliseconds to ensure system.error_log is flushed
|
||||
$CLICKHOUSE_CLIENT -mn -q "
|
||||
SELECT throwIf(true, 'error_log', toInt16(111)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 111 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(222)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 222 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(333)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 333 }
|
||||
SELECT sleep(2) format NULL;
|
||||
SYSTEM FLUSH LOGS;
|
||||
"
|
||||
|
||||
# Check that the three random errors are propagated
|
||||
$CLICKHOUSE_CLIENT -mn -q "
|
||||
SELECT sum(value) > $errors_111 FROM system.error_log WHERE code = 111;
|
||||
SELECT sum(value) > $errors_222 FROM system.error_log WHERE code = 222;
|
||||
SELECT sum(value) > $errors_333 FROM system.error_log WHERE code = 333;
|
||||
"
|
||||
|
||||
# Ensure that if we throw them again, they're still propagated
|
||||
$CLICKHOUSE_CLIENT -mn -q "
|
||||
SELECT throwIf(true, 'error_log', toInt16(111)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 111 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(222)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 222 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(333)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 333 }
|
||||
SELECT sleep(2) format NULL;
|
||||
SYSTEM FLUSH LOGS;
|
||||
"
|
||||
|
||||
$CLICKHOUSE_CLIENT -mn -q "
|
||||
SELECT sum(value) > $(($errors_111+1)) FROM system.error_log WHERE code = 111;
|
||||
SELECT sum(value) > $(($errors_222+1)) FROM system.error_log WHERE code = 222;
|
||||
SELECT sum(value) > $(($errors_333+1)) FROM system.error_log WHERE code = 333;
|
||||
"
|
@ -1,25 +0,0 @@
|
||||
-- Throw three random errors: 111, 222 and 333
|
||||
SELECT throwIf(true, 'error_log', toInt16(111)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 111 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(222)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 222 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(333)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 333 }
|
||||
|
||||
-- Wait for more than collect_interval_milliseconds to ensure system.error_log is flushed
|
||||
SELECT sleep(2) FORMAT NULL;
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
-- Check that the three random errors are propagated
|
||||
SELECT sum(value) > 0 FROM system.error_log WHERE code = 111 AND event_time > now() - INTERVAL 1 MINUTE;
|
||||
SELECT sum(value) > 0 FROM system.error_log WHERE code = 222 AND event_time > now() - INTERVAL 1 MINUTE;
|
||||
SELECT sum(value) > 0 FROM system.error_log WHERE code = 333 AND event_time > now() - INTERVAL 1 MINUTE;
|
||||
|
||||
-- Ensure that if we throw them again, they're still propagated
|
||||
SELECT throwIf(true, 'error_log', toInt16(111)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 111 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(222)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 222 }
|
||||
SELECT throwIf(true, 'error_log', toInt16(333)) SETTINGS allow_custom_error_code_in_throwif=1; -- { serverError 333 }
|
||||
|
||||
SELECT sleep(2) FORMAT NULL;
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
SELECT sum(value) > 1 FROM system.error_log WHERE code = 111 AND event_time > now() - INTERVAL 1 MINUTE;
|
||||
SELECT sum(value) > 1 FROM system.error_log WHERE code = 222 AND event_time > now() - INTERVAL 1 MINUTE;
|
||||
SELECT sum(value) > 1 FROM system.error_log WHERE code = 333 AND event_time > now() - INTERVAL 1 MINUTE;
|
Loading…
Reference in New Issue
Block a user