diff --git a/src/Core/Settings.h b/src/Core/Settings.h index c566d18ca4f..b589e30f594 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -224,6 +224,7 @@ class IColumn; /** Settings for testing hedged requests */ \ M(Milliseconds, sleep_in_send_tables_status_ms, 0, "Time to sleep in sending tables status response in TCPHandler", 0) \ M(Milliseconds, sleep_in_send_data_ms, 0, "Time to sleep in sending data in TCPHandler", 0) \ + M(UInt64, unknown_packet_in_send_data, 0, "Send unknown packet instead of data Nth data packet", 0) \ \ M(Bool, insert_allow_materialized_columns, 0, "If setting is enabled, Allow materialized columns in INSERT.", 0) \ M(Seconds, http_connection_timeout, DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT, "HTTP connection timeout.", 0) \ diff --git a/src/Server/TCPHandler.cpp b/src/Server/TCPHandler.cpp index c6cd74f6c6a..22a84ad2f11 100644 --- a/src/Server/TCPHandler.cpp +++ b/src/Server/TCPHandler.cpp @@ -1463,12 +1463,20 @@ void TCPHandler::sendData(const Block & block) try { + /// For testing hedged requests + const Settings & settings = query_context->getSettingsRef(); + if (settings.unknown_packet_in_send_data) + { + --const_cast(settings.unknown_packet_in_send_data).value; + if (settings.unknown_packet_in_send_data == 0) + writeVarUInt(UInt64(-1), *out); + } + writeVarUInt(Protocol::Server::Data, *out); /// Send external table name (empty name is the main table) writeStringBinary("", *out); /// For testing hedged requests - const Settings & settings = query_context->getSettingsRef(); if (block.rows() > 0 && settings.sleep_in_send_data_ms.totalMilliseconds()) { out->next(); diff --git a/tests/queries/0_stateless/01822_async_read_from_socket_crash.reference b/tests/queries/0_stateless/01822_async_read_from_socket_crash.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01822_async_read_from_socket_crash.sh b/tests/queries/0_stateless/01822_async_read_from_socket_crash.sh new file mode 100755 index 00000000000..d8c99a96854 --- /dev/null +++ b/tests/queries/0_stateless/01822_async_read_from_socket_crash.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + + + +for _ in {1..10}; do $CLICKHOUSE_CLIENT -q "select number from remote('127.0.0.{2,3}', numbers(20)) limit 8 settings max_block_size = 2, unknown_packet_in_send_data=4, sleep_in_send_data_ms=100, async_socket_for_remote=1 format Null" 2>&1 > /dev/null; done