Skip to content

Crash when selecting with FINAL and PREWHERE from table with ReplacingMergeTree engine #2525

@Schmak

Description

@Schmak

Environment:
Version: v1.1.54385-testing
Git hash: ba48e31
Docker image: sha256:2f64d4c08bbb10b415dac1ba78db82b0ef05b20b2b60dd0dd273a678964ae5ce
Can be reproduced on earlier builds too, but works well in:
Version: v1.1.54342-testing
Docker image: sha256:e4af84ec8e1a610e6b9aaef7c51135cbe017fdaca80170ee4b96d0d14086196f_

Create table and fill it with some data:

CREATE TABLE test (id String, version Date) ENGINE = ReplacingMergeTree(version, id, 8192)

INSERT INTO test (id, version) VALUES ('2018-01-01', '2018-01-01')

Request data with FINAL modifier and PREWHERE condition, which should return empty result set:

SELECT * FROM test FINAL 
PREWHERE id=='2018-01-02'

ClickHouse server crashes with the following stacktrace:

2018.06.18 10:48:53.691142 [ 1 ] <Error> Application: Cannot resolve listen_host (::), error -9: Address family for hostname not supported: -9. If it is an IPv6 address and your host has disabled IPv6, then consider to specify IPv4 address to listen in <listen_host> element of configuration file. Example: <listen_host>0.0.0.0</listen_host>
2018.06.18 10:48:53.691229 [ 1 ] <Error> Application: Listen [::]: -9: DNS error: Address family for hostname not supported: -9  If it is an IPv6 or IPv4 address and your host has disabled IPv6 or IPv4, then consider to specify not disabled IPv4 or IPv6 address to listen in <listen_host> element of configuration file. Example for disabled IPv6: <listen_host>0.0.0.0</listen_host> . Example for disabled IPv4: <listen_host>::</listen_host>
2018.06.18 10:49:31.080614 [ 22 ] <Error> BaseDaemon: ########################################
2018.06.18 10:49:31.080644 [ 22 ] <Error> BaseDaemon: (from thread 21) Received signal Segmentation fault (11).
2018.06.18 10:49:31.080655 [ 22 ] <Error> BaseDaemon: Address: NULL pointer.
2018.06.18 10:49:31.080665 [ 22 ] <Error> BaseDaemon: Access: read.
2018.06.18 10:49:31.080675 [ 22 ] <Error> BaseDaemon: Address not mapped to object.
2018.06.18 10:49:31.140609 [ 22 ] <Error> BaseDaemon: 0. /usr/bin/clickhouse-server(DB::ReplacingSortedBlockInputStream::insertRow(std::vector<COWPtr<DB::IColumn>::mutable_ptr<DB::IColumn>, std::allocator<COWPtr<DB::IColumn>::mutable_ptr<DB::IColumn> > >&, unsigned long&)+0x185) [0x803c775]
2018.06.18 10:49:31.140660 [ 22 ] <Error> BaseDaemon: 1. /usr/bin/clickhouse-server(DB::ReplacingSortedBlockInputStream::merge(std::vector<COWPtr<DB::IColumn>::mutable_ptr<DB::IColumn>, std::allocator<COWPtr<DB::IColumn>::mutable_ptr<DB::IColumn> > >&, std::priority_queue<DB::SortCursor, std::vector<DB::SortCursor, std::allocator<DB::SortCursor> >, std::less<DB::SortCursor> >&)+0x407) [0x803cca7]
2018.06.18 10:49:31.140681 [ 22 ] <Error> BaseDaemon: 2. /usr/bin/clickhouse-server(DB::ReplacingSortedBlockInputStream::readImpl()+0xf3) [0x803d763]
2018.06.18 10:49:31.140696 [ 22 ] <Error> BaseDaemon: 3. /usr/bin/clickhouse-server(DB::IProfilingBlockInputStream::read()+0x25a) [0x75f5d4a]
2018.06.18 10:49:31.140711 [ 22 ] <Error> BaseDaemon: 4. /usr/bin/clickhouse-server(DB::ExpressionBlockInputStream::readImpl()+0x2e) [0x7fd553e]
2018.06.18 10:49:31.140727 [ 22 ] <Error> BaseDaemon: 5. /usr/bin/clickhouse-server(DB::IProfilingBlockInputStream::read()+0x25a) [0x75f5d4a]
2018.06.18 10:49:31.140742 [ 22 ] <Error> BaseDaemon: 6. /usr/bin/clickhouse-server(DB::ExpressionBlockInputStream::readImpl()+0x2e) [0x7fd553e]
2018.06.18 10:49:31.140757 [ 22 ] <Error> BaseDaemon: 7. /usr/bin/clickhouse-server(DB::IProfilingBlockInputStream::read()+0x25a) [0x75f5d4a]
2018.06.18 10:49:31.140777 [ 22 ] <Error> BaseDaemon: 8. /usr/bin/clickhouse-server(DB::copyData(DB::IBlockInputStream&, DB::IBlockOutputStream&, std::atomic<bool>*)+0x81) [0x760b691]
2018.06.18 10:49:31.140799 [ 22 ] <Error> BaseDaemon: 9. /usr/bin/clickhouse-server(DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, bool, DB::Context&, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>)+0x563) [0x7d6f763]
2018.06.18 10:49:31.140817 [ 22 ] <Error> BaseDaemon: 10. /usr/bin/clickhouse-server(DB::HTTPHandler::processQuery(Poco::Net::HTTPServerRequest&, HTMLForm&, Poco::Net::HTTPServerResponse&, DB::HTTPHandler::Output&)+0x2d67) [0x2ce8787]
2018.06.18 10:49:31.140835 [ 22 ] <Error> BaseDaemon: 11. /usr/bin/clickhouse-server(DB::HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&)+0x24c) [0x2ceab0c]
2018.06.18 10:49:31.140850 [ 22 ] <Error> BaseDaemon: 12. /usr/bin/clickhouse-server(Poco::Net::HTTPServerConnection::run()+0x332) [0x86dcbf2]
2018.06.18 10:49:31.140865 [ 22 ] <Error> BaseDaemon: 13. /usr/bin/clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x86d549f]
2018.06.18 10:49:31.140880 [ 22 ] <Error> BaseDaemon: 14. /usr/bin/clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0x16a) [0x86d587a]
2018.06.18 10:49:31.140906 [ 22 ] <Error> BaseDaemon: 15. /usr/bin/clickhouse-server(Poco::PooledThread::run()+0x77) [0x8776a37]
2018.06.18 10:49:31.140920 [ 22 ] <Error> BaseDaemon: 16. /usr/bin/clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x38) [0x8772c48]
2018.06.18 10:49:31.140934 [ 22 ] <Error> BaseDaemon: 17. /usr/bin/clickhouse-server() [0x8dd3a8f]
2018.06.18 10:49:31.140948 [ 22 ] <Error> BaseDaemon: 18. /lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc) [0x7f03fbaf57fc]

If you omit FINAL modifier or use WHERE instead of PREWHERE or use condition which will return non-empty result set, then server will not crash.

See attached files for full log:

clickhouse-server.log
clickhouse-server.err.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions