ClickHouse / ClickHouse/ClickHouse

[CI crash] Failed to build query plan for join operation

Open
#115,142 3 comments 0 reactions 1 assignee Claimed by @devcrafter View on GitHub
close in a month if not active comp-parallel-replicas crash-ci
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

Stack trace details

The sipHash64(st.trace_full) is 15820952087388672655
The trace is from the master or release branch: True

The query for CIDB to compare the trace with the known one:

```sql
WITH
(
SELECT groupArrayDistinct(cleanStackTrace(trace_full) AS trace) FROM default.stack_traces
WHERE sipHash64(trace) IN (15820952087388672655, {ANOTHER_TRACE_HASH}) -- FIXME: replace with the known hash
) AS traces,
1.97 AS alpha,
stack_frame_weights AS (
WITH
(
SELECT count()
FROM default.stack_traces
FINAL
) AS total,
2.0 AS beta,
3.7 AS gamma
SELECT
arrayJoin(cleanStackTrace(trace_full)) AS frame,
countDistinct(trace_full) AS count,
log(total / count) AS IDF,
sigmoid(beta * (IDF - gamma)) AS weight
FROM default.stack_traces
FINAL
GROUP BY frame
),
(SELECT groupArray(weight) AS w, groupArray(frame) AS f FROM stack_frame_weights) AS weights,
(trace -> arrayMap((_frame, pos) -> (pow(pos, -alpha) * arrayFirst(w, f -> (f = _frame), weights.w, weights.f)), trace, arrayEnumerate(trace))) AS get_trace_weights,
(arr -> arrayStringConcat(arr, '\n')) AS joinArr

SELECT arraySimilarity(traces[1], traces[2], get_trace_weights(traces[1]) AS weights1, get_trace_weights(traces[2]) AS weights2) AS similarity,
arrayLevenshteinDistanceWeighted(traces[1], traces[2], weights1, weights2),
joinArr(traces[1]), joinArr(traces[2]), joinArr(weights1), joinArr(weights2)

```

The following new stack trace from CI Logs `system.crash_log` found:

```
DB::handle_error_code(String const&, std::basic_string_view>, int, bool, std::vector> const&)
DB::buildQueryTreeForShard(std::shared_ptr const&, std::shared_ptr, bool)
DB::ClusterProxy::executeQueryWithParallelReplicas(DB::QueryPlan&, DB::StorageID const&, DB::QueryProcessingStage::Enum, std::shared_ptr const&, std::shared_ptr const&, std::shared_ptr, std::shared_ptr> const>, std::unique_ptr>)
DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr, std::shared_ptr const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr&, bool, bool)
DB::buildJoinTreeQueryPlan(std::shared_ptr const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set, std::equal_to, std::allocator> const&, std::shared_ptr&)
DB::Planner::buildPlanForQueryNode()
DB::Planner::buildQueryPlanIfNeeded()
DB::InterpreterSelectQueryAnalyzer::getQueryPlan()
DB::executeQueryImpl(char const*, char const*, std::shared_ptr, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr>&, std::shared_ptr&, std::shared_ptr)
DB::executeQuery(String const&, std::shared_ptr, DB::QueryFlags, DB::QueryProcessingStage::Enum)
DB::TCPHandler::runImpl()
DB::TCPHandler::run()
Poco::Net::TCPServerConnection::start()
Poco::Net::TCPServerDispatcher::run()
Poco::PooledThread::run()
Poco::ThreadImpl::runnableEntry(void*)
```

Raw stack trace (with frame addresses)

```
3. ? @ 0x00000000000969fd
4. ? @ 0x0000000000042476
5. ? @ 0x00000000000287f3
6. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/Exception.cpp:51: DB::abortOnFailedAssertion(String const&, void* const*, unsigned long, unsigned long) @ 0x0000000014773919
7. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/Exception.cpp:84: DB::handle_error_code(String const&, std::basic_string_view>, int, bool, std::vector> const&) @ 0x00000000147743b0
8. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/Exception.cpp:135: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x00000000147746f9
9. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/Exception.h:123: DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000d39e6ce
10. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/Exception.h:58: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000d39e0d1
11. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/Exception.h:141: DB::Exception::Exception(int, FormatStringHelperImpl::type>, String&&) @ 0x000000000d39dcb6
12.0. inlined from /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Storages/buildQueryTreeForShard.cpp:376: DB::(anonymous namespace)::getSubqueryFromTableExpression(std::shared_ptr const&, std::unordered_map, DB::(anonymous namespace)::CollectColumnSourceToColumnsVisitor::Columns, std::hash>, std::equal_to>, std::allocator const, DB::(anonymous namespace)::CollectColumnSourceToColumnsVisitor::Columns>>> const&, std::shared_ptr const&)
12. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Storages/buildQueryTreeForShard.cpp:423: DB::buildQueryTreeForShard(std::shared_ptr const&, std::shared_ptr, bool) @ 0x000000001eaace69
13. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Interpreters/ClusterProxy/executeQuery.cpp:768: DB::ClusterProxy::executeQueryWithParallelReplicas(DB::QueryPlan&, DB::StorageID const&, DB::QueryProcessingStage::Enum, std::shared_ptr const&, std::shared_ptr const&, std::shared_ptr, std::shared_ptr> const>, std::unique_ptr>) @ 0x000000001e1d590e
14. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Planner/PlannerJoinTree.cpp:1289: DB::(anonymous namespace)::buildQueryPlanForTableExpression(std::shared_ptr, std::shared_ptr const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions const&, std::shared_ptr&, bool, bool) @ 0x000000001aee2a5f
15. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Planner/PlannerJoinTree.cpp:2517: DB::buildJoinTreeQueryPlan(std::shared_ptr const&, DB::SelectQueryInfo const&, DB::SelectQueryOptions&, std::unordered_set, std::equal_to, std::allocator> const&, std::shared_ptr&) @ 0x000000001aed6e39
16. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Planner/Planner.cpp:1641: DB::Planner::buildPlanForQueryNode() @ 0x000000001aebdef4
17. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Planner/Planner.cpp:1412: DB::Planner::buildQueryPlanIfNeeded() @ 0x000000001aebaaf0
18. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:269: DB::InterpreterSelectQueryAnalyzer::getQueryPlan() @ 0x000000001b813b8d
19. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Interpreters/executeQuery.cpp:1525: DB::executeQueryImpl(char const*, char const*, std::shared_ptr, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr>&, std::shared_ptr&, std::shared_ptr) @ 0x000000001bb15cd9
20. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Interpreters/executeQuery.cpp:1784: DB::executeQuery(String const&, std::shared_ptr, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x000000001bb0ff45
21. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Server/TCPHandler.cpp:739: DB::TCPHandler::runImpl() @ 0x000000001f5677a5
22. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Server/TCPHandler.cpp:2758: DB::TCPHandler::run() @ 0x000000001f581664
23. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/base/poco/Net/src/TCPServerConnection.cpp:40: Poco::Net::TCPServerConnection::start() @ 0x00000000277d1007
24. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x00000000277d15e5
25. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/base/poco/Foundation/src/ThreadPool.cpp:205: Poco::PooledThread::run() @ 0x00000000277707ff
26. /home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/base/poco/Foundation/src/Thread_POSIX.cpp:341: Poco::ThreadImpl::runnableEntry(void*) @ 0x000000002776ded1
27. ? @ 0x0000000000094ac3
28. ? @ 0x0000000000126850
```

Possible causes:
- Incorrectly formed join condition in query
- Missing or invalid table references in query
- Unsupported join type or configuration
- Problem with query plan generation logic
- Incompatible query tree structure during planning

The stack trace appeared in the following checks:
- [Stress test (amd_debug)](https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=25.8&sha=8ca297db6c85a7b59efa312329a196ef2d7f2400&name_0=ReleaseBranchCI&name_1=Stress%20test%20%28amd_debug%29&name_1=Stress%20test%20%28amd_debug%29)
- [Stress test (amd_ubsan)](https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=25.8&sha=8ca297db6c85a7b59efa312329a196ef2d7f2400&name_0=ReleaseBranchCI&name_1=Stress%20test%20%28amd_ubsan%29&name_1=Stress%20test%20%28amd_ubsan%29)
- [Stress test (arm_asan)](https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=25.8&sha=19fd660bebe63169084f6f61d4d58d9afd507649&name_0=ReleaseBranchCI&name_1=Stress%20test%20%28arm_asan%29&name_1=Stress%20test%20%28arm_asan%29)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.