Skip to content

Logical error: Expected JOIN table expression to be table, table function, query or union node #81144

@PedroTadim

Description

@PedroTadim

Describe the bug

Easy to reproduce. Seems related to parallel replicas.

How to reproduce

With the provided users.xml and config.xml configuration files:

users.txt
config.txt

run:

SET allow_experimental_parallel_reading_from_replicas = 1;
CREATE TABLE t0 (c0 Int) ENGINE = MergeTree() ORDER BY tuple();
SELECT * FROM (SELECT 1 FROM remote('localhost:9000', 'default', 't0') AS tx JOIN t0 ty ON TRUE RIGHT JOIN t0 ON TRUE); --Logical error

Error message and/or stacktrace

Stack trace:

<Fatal> : Logical error: 'Expected JOIN table expression to be table, table function, query or union node. Actual  INNER JOIN ... ON true'.
<Fatal> : Stack trace (when copying this message, always include the lines below):

0. std::exception::exception[abi:ne190107]() @ 0x0000000018295674
1. base/poco/Foundation/src/Exception.cpp:27: Poco::Exception::Exception(String const&, int) @ 0x0000000036c937a0
2. src/Common/Exception.cpp:110: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000024c8d6cb
3. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000018148516
4. DB::Exception::Exception<String>(int, FormatStringHelperImpl<std::type_identity<String>::type>, String&&) @ 0x000000001815ca4f
5. src/Storages/buildQueryTreeForShard.cpp:344: DB::buildQueryTreeForShard(std::shared_ptr<DB::PlannerContext> const&, std::shared_ptr<DB::IQueryTreeNode>, bool) @ 0x0000000031c6f043
6. src/Planner/findParallelReplicasQuery.cpp:497: DB::buildQueryPlanForParallelReplicas(DB::QueryNode const&, std::shared_ptr<DB::PlannerContext> const&, std::shared_ptr<std::list<DB::StorageLimits, std::allocator<DB::StorageLimits>> const>) @ 0x000000002e4f8355
7. src/Planner/Planner.cpp:1591: DB::Planner::buildPlanForQueryNode() @ 0x000000002e4d6fe4
8. src/Planner/Planner.cpp:1369: DB::Planner::buildQueryPlanIfNeeded() @ 0x000000002e4d24c9
9. src/Planner/Planner.cpp:251: DB::Planner::Planner(std::shared_ptr<DB::IQueryTreeNode> const&, DB::SelectQueryOptions&) @ 0x000000002e4d0e00
10. src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:183: DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const> const&, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&) @ 0x000000002f1c6d76
11. contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:634: std::__unique_if<DB::InterpreterSelectQueryAnalyzer>::__unique_single std::make_unique[abi:ne190107]<DB::InterpreterSelectQueryAnalyzer, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context> const&, DB::SelectQueryOptions const&>(std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context> const&, DB::SelectQueryOptions const&) @ 0x000000002f1cb62e
12. src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:307: std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> std::__function::__policy_invoker<std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments const&)>::__call_impl[abi:ne190107]<std::__function::__default_alloc_func<DB::registerInterpreterSelectQueryAnalyzer(DB::InterpreterFactory&)::$_0, std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments const&)>>(std::__function::__policy_storage const*, DB::InterpreterFactory::Arguments const&) @ 0x000000002f1cafa5
13. contrib/llvm-project/libcxx/include/__functional/function.h:716: ? @ 0x000000002f106e2f
14. src/Interpreters/executeQuery.cpp:1454: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*, std::shared_ptr<DB::IAST>&) @ 0x000000002f67a6d8
15. src/Interpreters/executeQuery.cpp:1714: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x000000002f674e74
16. src/Server/TCPHandler.cpp:687: DB::TCPHandler::runImpl() @ 0x0000000032b4d4dc
17. src/Server/TCPHandler.cpp:2677: DB::TCPHandler::run() @ 0x0000000032b7db2e
18. base/poco/Net/src/TCPServerConnection.cpp:40: Poco::Net::TCPServerConnection::start() @ 0x0000000036dc1f22
19. base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x0000000036dc2bf2
20. base/poco/Foundation/src/ThreadPool.cpp:205: Poco::PooledThread::run() @ 0x0000000036d27ff7
21. base/poco/Foundation/src/Thread_POSIX.cpp:335: Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000036d239ee
22. start_thread @ 0x00000000000a2ef1
23. __GI___clone3 @ 0x000000000013445c

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releasecomp-parallel-replicasParallel reading from replicas for query speed (not data replication consistency).fuzzProblem found by one of the fuzzersred CIVERY flaky test

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