Commit Graph

159 Commits

Author SHA1 Message Date
Vitaly Baranov
75735f1e94 Add test 2020-03-27 03:28:12 +03:00
Vitaly Baranov
34984d4a9a INSERT now clamps settings from initiator to shard's constraints. 2020-03-27 03:28:12 +03:00
alesapin
f6044c9c53 Add setting for a new format of distributed parts 2020-03-13 21:49:46 +03:00
Alexey Milovidov
cde492a784 clang-tidy, part 12 2020-03-09 04:22:33 +03:00
Alexey Milovidov
5b06842723 Remove excessive empty lines 2020-03-03 05:43:59 +03:00
Alexey Milovidov
766ae8261a Added some missing ErrorCodes 2020-02-25 21:02:41 +03:00
Alexey Milovidov
3602126a1e Remove unused ErrorCodes 2020-02-25 17:35:37 +03:00
Mikhail Korotov
5bd74b464d Merge branch 'secure_password' of https://github.com/millb/ClickHouse into secure_password 2020-02-12 13:08:10 +03:00
millb
92fc1a9b2b fixed bugs 2020-02-12 13:06:09 +03:00
Mikhail Korotov
f8db74fca6 Merge branch 'master' of https://github.com/ClickHouse/ClickHouse into secure_password 2020-02-11 13:51:37 +03:00
Artem Zuikov
bd6d9a427b
Some InterpreterSelectQuery refactoring (#9035)
move ExpressionActionsChain logic out of InterpreterSelectQuery
2020-02-10 18:50:12 +03:00
Mikhail Korotov
14acdffb0e
Update DirectoryMonitor.cpp 2020-01-31 14:29:21 +03:00
Mikhail Korotov
5c5b76d2b0
Update DirectoryMonitor.cpp 2020-01-31 14:28:39 +03:00
millb
d05642575d fixed 2020-01-31 14:16:46 +03:00
millb
165afabdd2 second attempt 2020-01-31 12:22:30 +03:00
Azat Khuzhin
e5a43d2751 Add ability to use multiple disks/volumes for Distributed engine
Now Distributed() has gain the 5-th argument -- policy name (for storing
data to send):

  CREATE TABLE foo (key Int) Engine=Distributed(test_shard_localhost, currentDatabase(), some_table, key%2, 'default');
2020-01-25 20:52:31 +03:00
Alexander Tokmakov
9389c83d4d Merge branch 'master' into table_name_in_istorage 2020-01-13 14:41:42 +03:00
alexey-milovidov
c270830b0a
Merge pull request #8535 from ClickHouse/distributed-format
Distributed format
2020-01-11 19:19:11 +03:00
Pradeep Chhetri
4941fdfe4b Fix some spelling mistakes 2020-01-11 17:51:33 +08:00
Nikolai Kochetov
f094e8f565 Support reading from DirectoryMonitor. 2020-01-04 21:33:16 +03:00
Nikolai Kochetov
5869d6708b Support reading from DirectoryMonitor. 2020-01-04 17:45:11 +03:00
Alexander Tokmakov
42296cc80a remove separate getTableName() and getDatabaseName() 2019-12-26 21:11:49 +03:00
Alexander Tokmakov
cf5c998b30 refactor storage name 2019-12-26 19:23:38 +03:00
Nikolai Kochetov
6a1dccd27c Change initialization order for StorageDistributedDirectoryMonitor members. 2019-12-24 21:25:00 +03:00
Alexander Tokmakov
d1568c1614 fix rename distributed 2019-12-19 22:51:12 +03:00
Vitaly Baranov
133675a86a Simplify format of the header of data sending to a shard in a distributed query. 2019-12-05 13:34:25 +03:00
Azat Khuzhin
3a72e1c12a Add checksum for extra info/query in distributed sends
This extras includes:
- server revision
- query settings
- query

Otherwise the code can try to interpret data, and got for instance
std::length_error exception, which is not catched (to mark the part as
broken). Also this will protect from the corruptions on disk.

And add a simple test, since dbms/tests/integration/test_insert_into_distributed too complex.

Also simplify the code by using readStringBinary() over
readVarUInt()+b.readStrict() (this also gains additional checks that
string is not bigger then 1GB).

Refs: #4852 (8ef7f3589a)
v2: avoid ABI breakage (suggested by @vitlibar)
v3: minor code fixes (suggested by @vitlibar) and as a consequence clang-8 build fix
v4: drop DBMS_MIN_REVISION_WITH_EXTRAS_CHECKSUM_IN_DIST_BATCH and also
    revert some renames to make the patch cleaner
2019-12-04 22:54:38 +03:00
Azat Khuzhin
362505b129 DirectoryMonitor: mark batch as broken on UNKNOWN_CODEC/CANNOT_DECOMPRESS errors
There is no point in retrying batch after those errors (for the same
reasons as CHECKSUM_DOESNT_MATCH is there).
2019-11-26 20:21:05 +03:00
Vitaly Baranov
f3d72b9ec1 Skip unknown settings with warnings. 2019-11-17 03:51:58 +03:00
Alexey Milovidov
9ac4e4c7fb Little better #7600 2019-11-05 22:31:07 +03:00
Azat Khuzhin
4dfffdd24a Write current batch for distributed send atomically (using .tmp + rename)
Otherwise the following can happen after reboot:

    2019.11.01 11:46:12.217143 [ 187 ] {} <Error> dist.Distributed.DirectoryMonitor: Code: 27, e.displayText() = DB::Exception: Cannot parse input: expected \n before: S\'^A\0^]\0\0<BE>4^A\0r<87>\0\0<A2><D7>^D^Y\0<F2>{^E<CD>\0\0Hy\0\0<F2>^_^C\0^_&\0\0<FF><D3>\0\0
    <8D><91>\0\0<C0>9\0\0<C0><B0>^A\0^G<AA>\0\0<B5><FE>^A\0<BF><A7>^A\0<9B><CB>^A\0I^R^A\0<B7><AB>^A\0<BC><8F>\0\0˲^B\0Zy\0\0<94><AA>\0\0<98>
    <8F>\0\0\f<A5>\0\0^QN\0\0<E3><C6>\0\0<B1>6^B\0ɳ\0\0W<99>\0\0<B9><A2>\0\0:<BB>\0\0)<B1>\0\0#<8B>\0\0aW\0\0<ED>#\0\0<F1>@\0\0ˀ^B\0<D7><FC>\0\0<DF>, Stack trace:

    0. 0x559e27222e60 StackTrace::StackTrace() /usr/bin/clickhouse
    1. 0x559e27222c45 DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) /usr/bin/clickhouse
    2. 0x559e26de4473 ? /usr/bin/clickhouse
    3. 0x559e272494b5 DB::assertString(char const*, DB::ReadBuffer&) /usr/bin/clickhouse
    4. 0x559e2a5dab45 DB::StorageDistributedDirectoryMonitor::processFilesWithBatching(std::map<unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&) /usr/bin/clickhouse
    5. 0x559e2a5db5fa DB::StorageDistributedDirectoryMonitor::processFiles() /usr/bin/clickhouse
    6. 0x559e2a5dba78 DB::StorageDistributedDirectoryMonitor::run() /usr/bin/clickhouse
    7. 0x559e2a5ddbbc ThreadFromGlobalPool::ThreadFromGlobalPool<void (DB::StorageDistributedDirectoryMonitor::*)(), DB::StorageDistributedDirectoryMonitor*>(void (DB::StorageDistributedDirectoryMonitor::*&&)(), DB::StorageDistributedDirectoryMonitor*&&)::{lambda()#1}::operator()() const /usr/bin/clickhouse
    8. 0x559e2726b07c ThreadPoolImpl<std::thread>::worker(std::_List_iterator<std::thread>) /usr/bin/clickhouse
    9. 0x559e2bbc3640 ? /usr/bin/clickhouse
    10. 0x7fbd62b3cfb7 start_thread /lib/x86_64-linux-gnu/libpthread-2.29.so
    11. 0x7fbd62a692ef __clone /lib/x86_64-linux-gnu/libc-2.29.so
     (version 19.17.1.1)

v2: remove fsync, to avoid possible stalls (https://github.com/ClickHouse/ClickHouse/pull/7600#discussion_r342010874)
2019-11-05 00:24:38 +03:00
Alexander Kuzmenkov
050de71ef4
Update DistributedBlockOutputStream.cpp 2019-10-24 12:33:45 +03:00
Azat Khuzhin
ab9d9f8997 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
2019-10-23 21:54:27 +03:00
tavplubix
0046b9f137 Wait for jobs to finish on exception (fixes rare segfaults) (#7350) 2019-10-17 17:41:27 +03:00
Alexander Kuzmenkov
8a1d57bddb Include PODArray.h into fewer files. 2019-10-11 14:28:16 +03:00
Azat Khuzhin
b22b65dd29
Avoid SIGSEGV on batch send failure (file with index XX is absent)
In case of the following error:
  Failed to send batch: file with index 23742 is absent

NULL dereference will occur for the "remote".
2019-09-21 02:22:25 +03:00
Azat Khuzhin
02befdd8c2
Introduce distributed_directory_monitor_max_sleep_time_ms setting
This will replace static 30 seconds max_sleep_time for the
StorageDistributedDirectoryMonitor, since in some cases 30 seconds can
be too large.
2019-09-12 03:16:06 +03:00
Vasily Nemkov
c2fc71b5e5 Post-PR fixes
Renamed settings, updated docs.
2019-09-05 13:35:36 +03:00
Vasily Nemkov
f98c488834 Post-review fixes
* Actually using the replica recovery settings for cluster
* A bit of doc on DBMS_CONNECTION_POOL_WITH_FAILOVER_MAX_ERROR_COUNT
* StorageDistributedDirectoryMonitor using settings for ConnectionPoolWithFailover
* Using SettingSeconds instead of SettingUInt64 for replica_error_decrease_period
2019-09-02 17:26:25 +03:00
Alexey Milovidov
6bbf3bd634 Added a metric for the number of files to send in Distributed tables 2019-08-22 04:30:49 +03:00
kreuzerkrieg
112fc71276 adding -Wshadow for GCC 2019-08-09 23:58:16 +03:00
Alexander Tokmakov
5cf183cbe3 fixes after review 2019-08-07 15:55:27 +03:00
Alexander Tokmakov
aefc664819 refactor throwFromErrno 2019-08-06 21:54:06 +03:00
alesapin
fd3abbe93d
Merge pull request #4935 from zhang2014/feature/support_system_replicas
Support system replicas queries for distributed
2019-06-17 15:30:30 +03:00
Konstantin Podshumok
a61a8386f3 update timeouts usage in DistributedBlockOutputStream 2019-06-02 12:43:20 +03:00
Konstantin Podshumok
b801fcb79a fix timeouts usage in directory monitor 2019-06-02 12:43:20 +03:00
zhang2014
80788cd7a8 Rename system sync distributed to system flush distributed 2019-05-29 10:43:52 +08:00
zhang2014
1a33840964 fix review 2019-05-29 10:43:52 +08:00
zhang2014
c44f608868 support replicas system queries for distributed 2019-05-29 10:43:52 +08:00
tai
b394a79af3 try fix batch async insert settings for Distributed 2019-04-29 17:02:23 +08:00