ClickHouse / ClickHouse

ClickHouse® is a real-time analytics DBMS
https://clickhouse.com
Apache License 2.0
37.64k stars 6.91k forks source link

clickhouse-client hangs when I paste 2 MB query in interactive command line. #12570

Closed alexey-milovidov closed 4 years ago

alexey-milovidov commented 4 years ago

Describe the bug

Generate the query with the following script:

perl -e 'print "SELECT [1" . (",1" x 1000000) . "]"'

Then copy it from terminal (you may need to setup unlimited scroll buffer to do this).

Run clickhouse-client in interactive mode and paste this query (you can do it with Ctrl+Shift+v, Shift+Insert or middle mouse button - doesn't matter).

client will hung without even consuming CPU.

alexey-milovidov commented 4 years ago
#0  __libc_write (nbytes=9437145, buf=0x7ffa24980700, fd=1) at ../sysdeps/unix/sysv/linux/write.c:26
#1  __libc_write (fd=1, buf=0x7ffa24980700, nbytes=9437145) at ../sysdeps/unix/sysv/linux/write.c:24
#2  0x00000000105958d5 in replxx::Terminal::write8 (this=<optimized out>, 
    data_=0x7ffa24980700 "SELECT \033[0;22;33m[\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033["..., size_=12288) at ../contrib/replxx/src/io.cxx:125
#3  replxx::Terminal::write32 (this=0x7ffa3af13980, 
    text32=0x7ffa2a9807c0 U"SELECT \033[0;22;33m[\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033[0;22;32m1\033[0;1m,\033["..., len32=9437145) at ../contrib/replxx/src/io.cxx:111
#4  0x000000001058b997 in replxx::Replxx::ReplxxImpl::refresh_line (this=0x7ffa3af13800, hintAction_=<optimized out>) at ../contrib/replxx/src/replxx_impl.cxx:773
#5  0x00000000105890aa in replxx::Replxx::ReplxxImpl::insert_character (this=0x7ffa3af13800, c=<optimized out>) at ../contrib/replxx/src/replxx_impl.cxx:1225
#6  0x000000001058d14b in replxx::Replxx::ReplxxImpl::action (this=0x7ffa3af13800, actionTrait_=34, handler_=<optimized out>, code_=613943040 U'\x24980700') at ../contrib/replxx/src/replxx_impl.cxx:1158
#7  replxx::Replxx::ReplxxImpl::get_input_line (this=0x7ffa3af13800) at ../contrib/replxx/src/replxx_impl.cxx:1151
#8  0x000000001058cb6b in replxx::Replxx::ReplxxImpl::input (this=0x7ffa3af13800, prompt=...) at ../contrib/replxx/src/replxx_impl.cxx:466
#9  0x000000001041eaf8 in ReplxxLineReader::readOneLine (this=0x7ffe11eb1f00, prompt=...) at ../base/common/ReplxxLineReader.cpp:92
#10 0x000000001041cd9c in LineReader::readLine (this=0x7ffe11eb1f00, first_prompt=..., second_prompt=...) at ../base/common/LineReader.cpp:81
#11 0x0000000009be6d07 in DB::Client::mainImpl (this=<optimized out>) at ../programs/client/Client.cpp:617
#12 0x0000000009be40b6 in DB::Client::main (this=0x7ffe11eb2250) at ../programs/client/Client.cpp:252
#13 0x000000001047bc3a in Poco::Util::Application::run (this=0x7ffe11eb2250) at ../contrib/poco/Util/src/Application.cpp:334
#14 0x0000000009bdc4a3 in mainEntryClickHouseClient (argc=1, argv=0x7ffa3ae08010) at ../programs/client/Client.cpp:2354
#15 0x0000000009b415c3 in main (argc_=<optimized out>, argv_=<optimized out>) at ../programs/main.cpp:324
alexey-milovidov commented 4 years ago

Looks like a bug in "Konsole" terminal emulator that I use. If I use "Kitty" it works perfectly.

alexey-milovidov commented 4 years ago

But if I paste into bash in Konsole it also works. Maybe because we issue a single write syscall with data of about 8 MB size and it triggers a bug in Konsole.

alexey-milovidov commented 4 years ago

When I kill process, the terminal remains hung and does not respond to any commands.

alexey-milovidov commented 4 years ago

Actually it is a bug in "midnight commander" (mc). It only reproduces if I paste query inside clickhouse-client from bash that is run by mc.

alexey-milovidov commented 4 years ago

The issue reproduces even if mc is run under kitty.