Fix Broken pipe error for 03149_numbers_max_block_size_zero.sh

The error appeared while debugging
https://github.com/ClickHouse/clickhouse-private/issues/14225

Logs:
https://pastila.nl/?00628486/754eaf7d96fd03ceecdf1a45458867dc#B9vFn07WAielph/Z5lHbrQ==

From the `man grep`:

>  -q, --quiet, --silent
> <...> Exit immediately with zero status if any match is found, even if an error was detected.

When `grep -q` finds a match, it immediately exits with status `0 and
closes its side of the pipe. If the clickhouse-client is still trying to
send data through the pipe, it leads to SIGPIPE signal.

Use grep -c instead. It is less efficient, but the output in this test
is small.

We should also revisit how we handle SIGPIPE signal,
e.g. the server should not try to send logs if it already encountered
the Broken pipe error.
This commit is contained in:
Julia Kartseva 2024-08-16 20:35:44 +00:00
parent eaa5715a02
commit faad7f4ba2

View File

@ -4,4 +4,4 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -q "SELECT count(*) FROM numbers(10) AS a, numbers(11) AS b, numbers(12) AS c SETTINGS max_block_size = 0" 2>&1 | grep -q "Sanity check: 'max_block_size' cannot be 0. Set to default value" && echo "OK" || echo "FAIL"
$CLICKHOUSE_CLIENT -q "SELECT count(*) FROM numbers(10) AS a, numbers(11) AS b, numbers(12) AS c SETTINGS max_block_size = 0" 2>&1 | [ $(grep -c "Sanity check: 'max_block_size' cannot be 0. Set to default value") -gt 0 ] && echo "OK" || echo "FAIL"