-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Materialized Views on system log tables don't work #10285
Description
view sql is:
CREATE MATERIALIZED VIEW table_slow_query_local ENGINE =MergeTree() PARTITION BY toDate(startTime) ORDER BY (query_id) TTL startTime+INTERVAL 90 DAY POPULATE
AS SELECT eventDate,startTime,status,useSeconds,readRows,resultRows,writeRows,writtenMB,memoryUsageMB,clusterName,serverName,serverIp,initial_query_id,query_id,queryFromHost FROM(
SELECT event_date AS eventDate,query_start_time AS startTime, multiIf(type = 1, 'start', type = 2, 'success',type = 3, 'errorBeforeStart',type = 4, 'errorProcessing', 'other') AS status,
query_duration_ms / 1000 AS useSeconds, read_rows AS readRows, result_rows AS resultRows, written_rows AS writeRows, written_bytes/1024/1024 AS writtenMB,
memory_usage / (1024 * 1024) AS memoryUsageMB, initial_query_id, query_id, substring(IPv6NumToString(address),8,15) AS queryFromHost,'1' joinkey
FROM system.query_log )a JOIN (SELECT cluster AS clusterName,host_name AS serverName,host_address AS serverIp,'1' joinkey
FROM system.clusters WHERE is_local LIMIT 1)b ON a.joinkey=b.joinkey;
Describe the bug
after create the above view,then when flush logs then throw errors is the clickhouse-server.log
How to reproduce
create the above view and tail the clickhouse-server.log can see the error and clickhouse cann't flush log to system.query_log.when delete the view,there is no error and flush log correctly.
- Which ClickHouse server version to use
20.1.6.30
Error message and/or stacktrace
2020.04.15 22:41:44.767768 [ 42 ] {} void DB::SystemLog::flushImpl(DB::SystemLog::EntryType) [with LogElement = DB::QueryLogElement]: Code: 393, e.displayText() = DB::Exception: There is no query, Stack trace (when copying this message, always include the lines below):
- 0x100ac1bc Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int) in /usr/bin/clickhouse
- 0x8e74849 DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int) in /usr/bin/clickhouse
- 0xcd7b5a6 ? in /usr/bin/clickhouse
- 0xcd6ef49 DB::Context::getSampleBlockCache() const in /usr/bin/clickhouse
- 0xd0b77d2 DB::InterpreterSelectWithUnionQuery::getSampleBlock(std::__1::shared_ptrDB::IAST const&, DB::Context const&) in /usr/bin/clickhouse
- 0xd2b2299 ? in /usr/bin/clickhouse
- 0xd2b51d8 DB::getDatabaseAndTablesWithColumnNames(std::__1::vector<DB::ASTTableExpression const*, std::__1::allocator<DB::ASTTableExpression const*> > const&, DB::Context const&, bool) in /usr/bin/clickhouse
- 0xd23130b DB::SyntaxAnalyzer::analyze(std::__1::shared_ptrDB::IAST&, DB::NamesAndTypesList const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&, std::__1::shared_ptrDB::IStorage, DB::NamesAndTypesList const&) const in /usr/bin/clickhouse
- 0xcef1d96 ? in /usr/bin/clickhouse
- 0xcef2f4e DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptrDB::IAST const&, DB::Context const&, std::__1::shared_ptrDB::IBlockInputStream const&, std::__1::shared_ptrDB::IStorage const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&) in /usr/bin/clickhouse
- 0xcef3f16 DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptrDB::IAST const&, DB::Context const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&) in /usr/bin/clickhouse
- 0xcebeaa2 DB::PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::shared_ptrDB::IStorage const&, DB::Context const&, std::__1::shared_ptrDB::IAST const&, bool) in /usr/bin/clickhouse
- 0xceb62cd DB::InterpreterInsertQuery::execute() in /usr/bin/clickhouse
- 0x8eecaca DB::SystemLogDB::QueryLogElement::flushImpl(DB::SystemLogDB::QueryLogElement::EntryType) in /usr/bin/clickhouse
- 0x8efeeed DB::SystemLogDB::QueryLogElement::threadFunction() in /usr/bin/clickhouse
- 0x8f00a50 ThreadFromGlobalPool::ThreadFromGlobalPool<DB::SystemLogDB::QueryLogElement::SystemLog(DB::Context&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, unsigned long)::'lambda'()>(DB::QueryLogElement&&, DB::SystemLogDB::QueryLogElement::SystemLog(DB::Context&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, unsigned long)::'lambda'()&&...)::'lambda'()::operator()() const in /usr/bin/clickhouse
- 0x8e97347 ThreadPoolImplstd::__1::thread::worker(std::__1::__list_iterator<std::__1::thread, void*>) in /usr/bin/clickhouse
- 0x8e9580f ? in /usr/bin/clickhouse
- 0x7e25 start_thread in /usr/lib64/libpthread-2.17.so
- 0xfebad __clone in /usr/lib64/libc-2.17.so
(version 20.1.6.30 (official build))