ClickHouse: Crash on MV Insert Into Locked Buffer Table With LowCardinality Key Column
ClickHouse 21.4.4
We are testing using buffer tables for materialized views to reduce the number of parts created during inserts. When trying to read from one of those buffer tables (using a Distributed table), ClickHouse crashed on multiple shards. This is the table:
(
`datetime` DateTime,
`svc_type` LowCardinality(String),
`svc` LowCardinality(String),
`cache_group` LowCardinality(String),
`client_status` Enum8('NONE' = 0, 'SUCCESS' = 1, 'CLIENT_ERROR' = 2, 'SERVER_ERROR' = 3),
`cache_result` Enum8('HIT' = 1, 'MISS' = 2, 'ERROR' = 3),
`event_count` UInt64,
`served_bytes` UInt64,
`parent_bytes` UInt64,
`ttms_avg` AggregateFunction(avg, UInt32),
`ttms_quants` AggregateFunction(quantilesTiming(0.99, 0.95, 0.9), UInt32),
`chi_count` AggregateFunction(uniq, FixedString(16)),
`manifest_count` UInt64,
`fragment_count` UInt64
)
ENGINE = Buffer('comcast_xcr', 'atsec_svc_1h_mt', 1, 30, 300, 10000, 1000000, 1000000, 100000000)
Note that this table has only one buffer “layer” (we don’t expect a huge number of inserts). It also relies on an implicit cast of String to LowCardinality String.
The crash (on 5 or 6 servers):
2021.05.15 20:51:20.446960 [ 399962 ] {} <Fatal> BaseDaemon: (version 21.4.4.30 (official build), build id: E3FA92117218D182F17C14F864FF4ED3D3689BFE) (from thread 2448209) (no query) Received signal Segmentation fault (11)
2021.05.15 20:51:20.446976 [ 399962 ] {} <Fatal> BaseDaemon: Address: NULL pointer. Access: read. Unknown si_code.
2021.05.15 20:51:20.447003 [ 399962 ] {} <Fatal> BaseDaemon: Stack trace: 0xf1439f7 0xf142358 0xf140dce 0xfa59948 0xfd529a0 0xfd52120 0xf4ba024 0xf4c3fdb 0xf4c45fc 0xf4c4679 0xf4bbb6f 0xfd4e458 0xfd4bd03 0xfd4eff5 0xf33b820 0xf33d817 0xf33e5e2 0x8954fef 0x8958a83 0x7fb34a24314a 0x7fb349f74f23
2021.05.15 20:51:20.475409 [ 399962 ] {} <Fatal> BaseDaemon: 1. DB::ReverseIndex<unsigned long, DB::ColumnString>::insert(StringRef const&) @ 0xf1439f7 in /usr/bin/clickhouse
2021.05.15 20:51:20.475428 [ 399962 ] {} <Fatal> BaseDaemon: 2. COW<DB::IColumn>::mutable_ptr<DB::IColumn> DB::ColumnUnique<DB::ColumnString>::uniqueInsertRangeImpl<char8_t>(DB::IColumn const&, unsigned long, unsigned long, unsigned long, DB::ColumnVector<char8_t>::MutablePtr&&, DB::ReverseIndex<unsigned long, DB::ColumnString>*, unsigned long) @ 0xf142358 in /usr/bin/clickhouse
2021.05.15 20:51:20.475436 [ 399962 ] {} <Fatal> BaseDaemon: 3. DB::ColumnUnique<DB::ColumnString>::uniqueInsertRangeFrom(DB::IColumn const&, unsigned long, unsigned long) @ 0xf140dce in /usr/bin/clickhouse
2021.05.15 20:51:20.475447 [ 399962 ] {} <Fatal> BaseDaemon: 4. DB::ColumnLowCardinality::insertRangeFrom(DB::IColumn const&, unsigned long, unsigned long) @ 0xfa59948 in /usr/bin/clickhouse
2021.05.15 20:51:20.475456 [ 399962 ] {} <Fatal> BaseDaemon: 5. DB::BufferBlockOutputStream::insertIntoBuffer(DB::Block const&, DB::StorageBuffer::Buffer&) @ 0xfd529a0 in /usr/bin/clickhouse
2021.05.15 20:51:20.475461 [ 399962 ] {} <Fatal> BaseDaemon: 6. DB::BufferBlockOutputStream::write(DB::Block const&) @ 0xfd52120 in /usr/bin/clickhouse
2021.05.15 20:51:20.475470 [ 399962 ] {} <Fatal> BaseDaemon: 7. DB::PushingToViewsBlockOutputStream::write(DB::Block const&) @ 0xf4ba024 in /usr/bin/clickhouse
2021.05.15 20:51:20.475476 [ 399962 ] {} <Fatal> BaseDaemon: 8. DB::AddingDefaultBlockOutputStream::write(DB::Block const&) @ 0xf4c3fdb in /usr/bin/clickhouse
2021.05.15 20:51:20.475483 [ 399962 ] {} <Fatal> BaseDaemon: 9. DB::SquashingBlockOutputStream::finalize() @ 0xf4c45fc in /usr/bin/clickhouse
2021.05.15 20:51:20.475488 [ 399962 ] {} <Fatal> BaseDaemon: 10. DB::SquashingBlockOutputStream::writeSuffix() @ 0xf4c4679 in /usr/bin/clickhouse
2021.05.15 20:51:20.475493 [ 399962 ] {} <Fatal> BaseDaemon: 11. DB::PushingToViewsBlockOutputStream::writeSuffix() @ 0xf4bbb6f in /usr/bin/clickhouse
2021.05.15 20:51:20.475499 [ 399962 ] {} <Fatal> BaseDaemon: 12. DB::StorageBuffer::writeBlockToDestination(DB::Block const&, std::__1::shared_ptr<DB::IStorage>) @ 0xfd4e458 in /usr/bin/clickhouse
2021.05.15 20:51:20.475506 [ 399962 ] {} <Fatal> BaseDaemon: 13. DB::StorageBuffer::flushBuffer(DB::StorageBuffer::Buffer&, bool, bool, bool) @ 0xfd4bd03 in /usr/bin/clickhouse
2021.05.15 20:51:20.475511 [ 399962 ] {} <Fatal> BaseDaemon: 14. DB::StorageBuffer::backgroundFlush() @ 0xfd4eff5 in /usr/bin/clickhouse
2021.05.15 20:51:20.475519 [ 399962 ] {} <Fatal> BaseDaemon: 15. DB::BackgroundSchedulePoolTaskInfo::execute() @ 0xf33b820 in /usr/bin/clickhouse
2021.05.15 20:51:20.475524 [ 399962 ] {} <Fatal> BaseDaemon: 16. DB::BackgroundSchedulePool::threadFunction() @ 0xf33d817 in /usr/bin/clickhouse
2021.05.15 20:51:20.475529 [ 399962 ] {} <Fatal> BaseDaemon: 17. ? @ 0xf33e5e2 in /usr/bin/clickhouse
2021.05.15 20:51:20.475539 [ 399962 ] {} <Fatal> BaseDaemon: 18. ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) @ 0x8954fef in /usr/bin/clickhouse
2021.05.15 20:51:20.475544 [ 399962 ] {} <Fatal> BaseDaemon: 19. ? @ 0x8958a83 in /usr/bin/clickhouse
2021.05.15 20:51:20.475557 [ 399962 ] {} <Fatal> BaseDaemon: 20. start_thread @ 0x814a in /usr/lib64/libpthread-2.28.so
2021.05.15 20:51:20.475567 [ 399962 ] {} <Fatal> BaseDaemon: 21. clone @ 0xfcf23 in /usr/lib64/libc-2.28.so
2021.05.15 20:51:20.576475 [ 399962 ] {} <Fatal> BaseDaemon: Checksum of the binary: 21B45BF98BF6821B2FE099092F5117E8, integrity check passed.
2021.05.15 20:51:42.120885 [ 2446750 ] {} <Fatal> Application: Child process was terminated by signal 11.
Everything seems fine if we don’t try to read from the buffer table.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (16 by maintainers)
even easier:
I have prepared a minimal example that reproduces this crash. The issue is related to the Buffer Engine, that has a LowCardinality(String) field, is being inserted into and read from with a select statement that uses the GROUP BY clause.
The buffer is as follows:
Inserting and selecting from the buffer is done with the following Python program:
inserts.py
selects.py
main.py
When the program is ran, it manages to make one insert and crashes Clickhouse:
Crash log: