Reconnect after client errors

This commit is contained in:
Alexander Kuzmenkov 2021-01-21 17:28:46 +03:00
parent 8663d04b7f
commit ec8ff21526
5 changed files with 52 additions and 2 deletions

View File

@ -680,6 +680,12 @@ private:
std::cerr << std::endl;
client_exception.reset(new Exception(e));
}
if (client_exception)
{
/// client_exception may have been set above or elsewhere.
/// Client-side exception during query execution can result in the loss of
/// sync in the connection protocol.
/// So we reconnect and allow to enter the next query.
@ -937,7 +943,7 @@ private:
if (client_exception)
{
fmt::print(stderr,
"Error on processing query '{}':\n{}",
"Error on processing query '{}':\n{}\n",
full_query, client_exception->message());
}

View File

@ -649,7 +649,7 @@ def main(args):
def is_test_from_dir(suite_dir, case):
case_file = os.path.join(suite_dir, case)
(name, ext) = os.path.splitext(case)
return os.path.isfile(case_file) and (ext == '.sql' or ext == '.sh' or ext == '.py')
return os.path.isfile(case_file) and (ext == '.sql' or ext == '.sh' or ext == '.py' or ext == '.expect' or os.access(case_file, os. X_OK))
def sute_key_func(item):
if args.order == 'random':

View File

@ -42,5 +42,10 @@ OPTIMIZE TABLE values_01564 DEDUPLICATE BY; -- { clientError 62 }
OPTIMIZE TABLE values_01564 DEDUPLICATE BY a EXCEPT a; -- { clientError 62 }
select 'a' || distinct one || 'c' from system.one; -- { clientError 62 }
-- a failing insert and then a normal insert (#https://github.com/ClickHouse/ClickHouse/issues/19353)
CREATE TABLE t0 (c0 String, c1 Int32) ENGINE = Memory() ;
INSERT INTO t0(c0, c1) VALUES ("1",1) ; -- { clientError 47 }
INSERT INTO t0(c0, c1) VALUES ('1', 1) ;
-- the return code must be zero after the final query has failed with expected error
insert into values_01564 values (11); -- { serverError 469 }

View File

@ -0,0 +1,39 @@
#!/usr/bin/expect -f
# This is a separate test, because we want to test the interactive mode.
# https://github.com/ClickHouse/ClickHouse/issues/19353
log_user 0
set timeout 5
match_max 100000
# A default timeout action is to fail
expect_after {
timeout {
exit 1
}
}
set basedir [file dirname $argv0]
spawn bash -c "source $basedir/../shell_config.sh ; \$CLICKHOUSE_CLIENT_BINARY \$CLICKHOUSE_CLIENT_OPT -mn"
expect "\n:) "
send -- "DROP TABLE IF EXISTS t01565;\n"
expect "\nOk."
expect "\n:)"
send -- "CREATE TABLE t01565 (c0 String, c1 Int32) ENGINE = Memory() ;\n"
expect "\nOk."
expect "\n:) "
send -- "INSERT INTO t01565(c0, c1) VALUES (\"1\",1) ;\n"
expect "\nConnected"
expect "\n:) "
send -- "INSERT INTO t01565(c0, c1) VALUES ('1', 1) ;\n"
expect "\nOk."
expect "\n:) "
# Ctrl+D
send -- "\4"
expect eof