ClickHouse/dbms/programs/server
Alexander Kuzmenkov 29052b6a37
Merge pull request #7377 from azat/INSERT-Distributed-MATERIALIZED-cols
* Fix INSERT into Distributed non local node with MATERIALIZED columns

Previous patch e527def18a ("Fix INSERT
into Distributed() table with MATERIALIZED column") fixes it only for
cases when the node is local, i.e. direct insert.

This patch address the problem when the node is not local
(`is_local == false`), by erasing materialized columns on INSERT into
Distributed.

And this patch fixes two cases, depends on `insert_distributed_sync`
setting:

- `insert_distributed_sync=0`

    ```
    Not found column value in block. There are only columns: date. Stack trace:

    2. 0x7ffff7be92e0 DB::Exception::Exception() dbms/src/Common/Exception.h:27
    3. 0x7fffec5d6cf6 DB::Block::getByName(...) dbms/src/Core/Block.cpp:187
    4. 0x7fffec2fe067 DB::NativeBlockInputStream::readImpl() dbms/src/DataStreams/NativeBlockInputStream.cpp:159
    5. 0x7fffec2d223f DB::IBlockInputStream::read() dbms/src/DataStreams/IBlockInputStream.cpp:61
    6. 0x7ffff7c6d40d DB::TCPHandler::receiveData() dbms/programs/server/TCPHandler.cpp:971
    7. 0x7ffff7c6cc1d DB::TCPHandler::receivePacket() dbms/programs/server/TCPHandler.cpp:855
    8. 0x7ffff7c6a1ef DB::TCPHandler::readDataNext(unsigned long const&, int const&) dbms/programs/server/TCPHandler.cpp:406
    9. 0x7ffff7c6a41b DB::TCPHandler::readData(DB::Settings const&) dbms/programs/server/TCPHandler.cpp:437
    10. 0x7ffff7c6a5d9 DB::TCPHandler::processInsertQuery(DB::Settings const&) dbms/programs/server/TCPHandler.cpp:464
    11. 0x7ffff7c687b5 DB::TCPHandler::runImpl() dbms/programs/server/TCPHandler.cpp:257
    ```

- `insert_distributed_sync=1`

    ```
    2019.10.18 13:23:22.114578 [ 44 ] {a78f669f-0b08-4337-abf8-d31e958f6d12} <Error> executeQuery: Code: 171, e.displayText() = DB::Exception: Block structure mismatch in RemoteBlockOutputStream stream: different number of columns:
    date Date UInt16(size = 1), value Date UInt16(size = 1)
    date Date UInt16(size = 0): Insertion status:
    Wrote 1 blocks and 0 rows on shard 0 replica 0, 127.0.0.1:59000 (average 0 ms per block)
    Wrote 0 blocks and 0 rows on shard 1 replica 0, 127.0.0.2:59000 (average 2 ms per block)
     (version 19.16.1.1) (from [::1]:3624) (in query: INSERT INTO distributed_00952 VALUES ), Stack trace:

    2. 0x7ffff7be92e0 DB::Exception::Exception() dbms/src/Common/Exception.h:27
    3. 0x7fffec5da4e9 DB::checkBlockStructure<void>(...)::{...}::operator()(...) const dbms/src/Core/Block.cpp:460
    4. 0x7fffec5da671 void DB::checkBlockStructure<void>(...) dbms/src/Core/Block.cpp:467
    5. 0x7fffec5d8d58 DB::assertBlocksHaveEqualStructure(...) dbms/src/Core/Block.cpp:515
    6. 0x7fffec326630 DB::RemoteBlockOutputStream::write(DB::Block const&) dbms/src/DataStreams/RemoteBlockOutputStream.cpp:68
    7. 0x7fffe98bd154 DB::DistributedBlockOutputStream::runWritingJob(DB::DistributedBlockOutputStream::JobReplica&, DB::Block const&)::{lambda()#1}::operator()() const dbms/src/Storages/Distributed/DistributedBlockOutputStream.cpp:280
    <snip>
    ````

Fixes: #7365
Fixes: #5429
Refs: #6891

* Cover INSERT into Distributed with MATERIALIZED columns and !is_local node

I guess that adding new cluster into server-test.xml is not required,
but it won't harm.

* Update DistributedBlockOutputStream.cpp
2019-10-24 12:35:09 +03:00
..
config.d Added example config with macros 2019-10-09 04:15:23 +03:00
data Support for bitmapHasAny and bitmapHasAll functions. 2019-05-12 17:47:31 +03:00
metadata/default Squashed #2471 2018-06-05 23:09:51 +03:00
users.d Tests: fix call .sh from .sh (#4732) 2019-03-20 23:04:49 +03:00
clickhouse-server.cpp Squashed #2471 2018-06-05 23:09:51 +03:00
CMakeLists.txt Build fixes (#7063) 2019-10-05 22:25:31 +03:00
config.xml Cover INSERT into Distributed with MATERIALIZED columns and !is_local node 2019-10-23 21:55:08 +03:00
HTTPHandler.cpp Do not include Field.h everywhere through SettingsCommon.h. 2019-10-07 20:23:05 +03:00
HTTPHandler.h CHYT-67: introduce host context for using CH as a library. 2019-03-06 19:47:47 +03:00
HTTPHandlerFactory.h Added some warnings from clang's -Weverything 2019-01-04 15:10:00 +03:00
InterserverIOHTTPHandler.cpp CLICKHOUSE-4509 Fix error codes in DataPartsExchange 2019-05-20 20:04:36 +03:00
InterserverIOHTTPHandler.h CLICKHOUSE-4509 Fix error codes in DataPartsExchange 2019-05-20 20:04:36 +03:00
IServer.h Squashed #2471 2018-06-05 23:09:51 +03:00
MetricsTransmitter.cpp Avoid use of uninitialized values in MetricsTransmitter 2019-10-01 10:16:39 +03:00
MetricsTransmitter.h Avoid use of uninitialized values in MetricsTransmitter 2019-10-01 10:16:39 +03:00
MySQLHandler.cpp Move authentication code to a separate class. 2019-10-11 00:18:52 +03:00
MySQLHandler.h Build fixes (#7063) 2019-10-05 22:25:31 +03:00
MySQLHandlerFactory.cpp Build fixes (#7063) 2019-10-05 22:25:31 +03:00
MySQLHandlerFactory.h Build fixes (#7063) 2019-10-05 22:25:31 +03:00
NotFoundHandler.cpp Squashed #2471 2018-06-05 23:09:51 +03:00
NotFoundHandler.h Squashed #2471 2018-06-05 23:09:51 +03:00
PingRequestHandler.cpp Squashed #2471 2018-06-05 23:09:51 +03:00
PingRequestHandler.h Squashed #2471 2018-06-05 23:09:51 +03:00
ReplicasStatusHandler.cpp impr Lazy database 2019-10-01 15:44:17 +03:00
ReplicasStatusHandler.h Squashed #2471 2018-06-05 23:09:51 +03:00
RootRequestHandler.cpp Squashed #2471 2018-06-05 23:09:51 +03:00
RootRequestHandler.h Squashed #2471 2018-06-05 23:09:51 +03:00
Server.cpp Build fixes (#7063) 2019-10-05 22:25:31 +03:00
Server.h Attempt to simplify text log 2019-08-04 18:51:04 +03:00
TCPHandler.cpp better scalar query 2019-10-23 21:37:54 +08:00
TCPHandler.h better scalar query 2019-10-23 21:37:54 +08:00
TCPHandlerFactory.h Squashed #2471 2018-06-05 23:09:51 +03:00
users.xml implemented mysql_native_password auth plugin for compatibility with mysqljs 2019-07-28 16:12:26 +03:00