Before this patch if the query failes (due to "Too many simultaneous
queries" for example) it will not read external tables info, and the
next request will interpret them as the query beginning at got:
DB::Exception: Unknown packet 11861 from client
v2: reordering in the executeQuery() is not enough, since the query
can fail in other places, before, i.e. quotas
v3: I cannot make non-intergration test (since there is no ability to
receive "Unknown packet" via client, only from the server log),
hence added one
stracktrace:
...
2 DB::WriteBuffer::nextIfAtEnd (this=0x0) at ../dbms/src/IO/WriteBuffer.h:66
3 DB::writeVarUInt (ostr=..., x=3) at ../dbms/src/IO/VarInt.h:191
4 DB::Connection::sendCancel (this=0x7f0b7f5e5610) at ../dbms/src/Client/Connection.cpp:444
5 0x0000561738d0b565 in DB::MultiplexedConnections::sendCancel (this=0x7f0c9b0173e0) at ../dbms/src/Client/MultiplexedConnections.cpp:174
6 0x00005617387d22df in DB::RemoteBlockInputStream::tryCancel (this=0x7f0cc45f9810, reason=<optimized out>) at /usr/include/c++/9/bits/unique_ptr.h:352
7 0x00005617387d2a37 in DB::RemoteBlockInputStream::cancel (this=<optimized out>, kill=false) at ../dbms/src/DataStreams/RemoteBlockInputStream.cpp:121
8 0x000056173891f10c in DB::ParallelInputsProcessor<DB::UnionBlockInputStream::Handler>::cancel (this=0x7f0c370ec168, kill=kill@entry=false)
9 0x000056173892cfce in DB::UnionBlockInputStream::cancel (kill=false, this=<optimized out>) at ../dbms/src/DataStreams/UnionBlockInputStream.h:99
10 DB::UnionBlockInputStream::Handler::onException (this=0x7f0c370ec160, exception=...) at ../dbms/src/DataStreams/UnionBlockInputStream.h:240
11 DB::ParallelInputsProcessor<DB::UnionBlockInputStream::Handler>::thread (this=0x7f0c370ec168, thread_group=..., thread_num=<optimized out>)
at ../dbms/src/DataStreams/ParallelInputsProcessor.h:217
And in onException frame there is:
(gdb) p ((DB::Exception *)exception._M_exception_object)._msg._M_dataplus._M_p
$6 = (...) 0x7f0c9b1e7a40 "Unknown packet 9 from server HOSTNAME:PORT"
And on "Unknown packet" there is disconnect() before, see default in
switch statement at Connection::receivePacket().