mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #16047 from ClickHouse/suggest-destruction-order
Fix destruction order of Suggest #16035
This commit is contained in:
commit
ae4d66ac9d
@ -218,6 +218,8 @@ private:
|
||||
QueryFuzzer fuzzer;
|
||||
int query_fuzzer_runs = 0;
|
||||
|
||||
std::optional<Suggest> suggest;
|
||||
|
||||
/// We will format query_id in interactive mode in various ways, the default is just to print Query id: ...
|
||||
std::vector<std::pair<String, String>> query_id_formats;
|
||||
|
||||
@ -577,10 +579,11 @@ private:
|
||||
if (print_time_to_stderr)
|
||||
throw Exception("time option could be specified only in non-interactive mode", ErrorCodes::BAD_ARGUMENTS);
|
||||
|
||||
suggest.emplace();
|
||||
if (server_revision >= Suggest::MIN_SERVER_REVISION && !config().getBool("disable_suggestion", false))
|
||||
{
|
||||
/// Load suggestion data from the server.
|
||||
Suggest::instance().load(connection_parameters, config().getInt("suggestion_limit"));
|
||||
suggest->load(connection_parameters, config().getInt("suggestion_limit"));
|
||||
}
|
||||
|
||||
/// Load command history if present.
|
||||
@ -607,7 +610,7 @@ private:
|
||||
highlight_callback = highlight;
|
||||
|
||||
ReplxxLineReader lr(
|
||||
Suggest::instance(),
|
||||
*suggest,
|
||||
history_file,
|
||||
config().has("multiline"),
|
||||
query_extenders,
|
||||
@ -615,7 +618,7 @@ private:
|
||||
highlight_callback);
|
||||
|
||||
#elif defined(USE_READLINE) && USE_READLINE
|
||||
ReadlineLineReader lr(Suggest::instance(), history_file, config().has("multiline"), query_extenders, query_delimiters);
|
||||
ReadlineLineReader lr(*suggest, history_file, config().has("multiline"), query_extenders, query_delimiters);
|
||||
#else
|
||||
LineReader lr(history_file, config().has("multiline"), query_extenders, query_delimiters);
|
||||
#endif
|
||||
|
@ -18,10 +18,11 @@ namespace ErrorCodes
|
||||
class Suggest : public LineReader::Suggest, boost::noncopyable
|
||||
{
|
||||
public:
|
||||
static Suggest & instance()
|
||||
Suggest();
|
||||
~Suggest()
|
||||
{
|
||||
static Suggest instance;
|
||||
return instance;
|
||||
if (loading_thread.joinable())
|
||||
loading_thread.join();
|
||||
}
|
||||
|
||||
void load(const ConnectionParameters & connection_parameters, size_t suggestion_limit);
|
||||
@ -30,12 +31,6 @@ public:
|
||||
static constexpr int MIN_SERVER_REVISION = 54406;
|
||||
|
||||
private:
|
||||
Suggest();
|
||||
~Suggest()
|
||||
{
|
||||
if (loading_thread.joinable())
|
||||
loading_thread.join();
|
||||
}
|
||||
|
||||
void loadImpl(Connection & connection, const ConnectionTimeouts & timeouts, size_t suggestion_limit);
|
||||
void fetch(Connection & connection, const ConnectionTimeouts & timeouts, const std::string & query);
|
||||
|
12
tests/queries/0_stateless/01526_client_start_and_exit.expect
Executable file
12
tests/queries/0_stateless/01526_client_start_and_exit.expect
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
log_user 1
|
||||
set timeout 5
|
||||
match_max 100000
|
||||
|
||||
if ![info exists env(CLICKHOUSE_PORT_TCP)] {set env(CLICKHOUSE_PORT_TCP) 9000}
|
||||
|
||||
spawn bash -c "clickhouse-client --port $env(CLICKHOUSE_PORT_TCP) && echo $?"
|
||||
expect ":) "
|
||||
send -- "\4"
|
||||
expect eof
|
@ -0,0 +1 @@
|
||||
Loaded 10000 queries.
|
23
tests/queries/0_stateless/01526_client_start_and_exit.sh
Executable file
23
tests/queries/0_stateless/01526_client_start_and_exit.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
# Create a huge amount of tables, so Suggest will take a time to load
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT 'CREATE TABLE test_' || hex(randomPrintableASCII(40)) || '(x UInt8) Engine=Memory;' FROM numbers(10000)" --format=TSVRaw | ${CLICKHOUSE_BENCHMARK} -c32 -i 10000 -d 0 2>&1 | grep -F 'Loaded 10000 queries'
|
||||
|
||||
function stress()
|
||||
{
|
||||
while true; do
|
||||
"${CURDIR}"/01526_client_start_and_exit.expect | grep -v -P 'ClickHouse client|Connecting|Connected|:\) Bye\.|^\s*$|spawn bash|^0\s*$'
|
||||
done
|
||||
}
|
||||
|
||||
export CURDIR
|
||||
export -f stress
|
||||
|
||||
for _ in {1..10}; do
|
||||
timeout 3 bash -c stress &
|
||||
done
|
||||
|
||||
wait
|
Loading…
Reference in New Issue
Block a user