Repository navigation
Fallback to local execution when distributed plan references dictionary - #121198
Conversation
|
Workflow [PR], commit [f16afc9] Summary: ✅
AI ReviewSummaryThis PR teaches the distributed-plan fallback to keep several dictionary-using plan fragments on the initiator instead of trying to serialize them to workers. The direct detection coverage is much better now, but one remote-filter pushdown path still lets a dictionary predicate move back onto the shard after the fallback decision, so the Findings❌ Blockers
Tests
Final Verdict
LLVM Coverage ReportMeasured on commit f16afc9.
Changed lines: Changed C/C++ lines covered: 73/85 (85.88%) · Uncovered code |
alesapin
left a comment
There was a problem hiding this comment.
LGTM, but let's fix bot comment. It refers to this code https://github.com/ClickHouse/clickhouse/blob/master/src/Processors/QueryPlan/Optimizations/mergeFilterIntoJoinCondition.cpp#L150-L253
groeneai
left a comment
There was a problem hiding this comment.
Reviewed at your request. The lambda gap is answered in the thread above, with a pointer to an existing
helper that already does that traversal. One test point on top of it.
test_dict_get_falls_back and test_dict_get_in_filter_falls_back assert
ProfileEvents['DistributedPlanRemoteTasks'] == 0 and zero worker query_log rows. Both hold when the
fallback works, and both also hold if this rig stops distributing anything at all: a missing key in a
ProfileEvents map reads as 0 (SELECT map('a',1)['b'] is 0), and a worker that never receives a task
logs nothing. test_strict_mode_throws does not separate the two cases either, because the throw comes
from the planning decision and needs no worker. A positive control in the same module, same settings, with
no dictionary reference (SELECT count() FROM t), asserting DistributedPlanRemoteTasks > 0 on the
initiator and one worker query_log row, makes those zeros load-bearing; the ProfileEvent is documented
for exactly that ("a non-zero value means the query was actually executed distributedly"). It matters more
once the lambda shapes are added to this file, since those are the cases where a plan really does reach a worker.
Three things I checked that need nothing: all 43 dict% functions in system.functions match
functionIsDictGet; reading a dictionary as a table (FROM d, dictionary(d)) plans as
ReadFromStorage (Dictionary), which ReadFromStorageStep::isSerializable already rejects (it accepts
SystemOne only); and WITH TOTALS is rejected earlier in getReasonStepCannotBeDistributed, so the
TotalsHaving actions sitting outside findDictionaryFunction is moot.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units13 translation units recompiled, 84 s compile time in total, 13 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Thanks, I took into account @groeneai's comment here, since machinery already exists: #121198 (comment) |
| if (const auto & row_level_filter = source->getRowLevelFilter()) | ||
| if (auto name = find_in_dag(row_level_filter->actions)) | ||
| return name; | ||
| if (const auto & filter_dag = source->getFilterActionsDAG()) |
There was a problem hiding this comment.
Disabling make_distributed_plan here does not fully preserve the "dictionary stays local" invariant for remote sources. applyDistributedPlanFallbackToLocal runs before QueryPlan::optimize, but later optimizePrimaryKeyConditionAndLimit still folds enclosing FilterSteps into any SourceStepWithFilterBase when query_plan_optimize_primary_key is enabled. For ReadFromRemote, addPipe then injects filter_actions_dag back into the shard query, so a query like SELECT count() FROM remote(...) WHERE dictHas(...) SETTINGS make_distributed_plan = 1 can still evaluate the dictionary on the remote host and fail if the dictionary exists only on the initiator. That breaks the fallback invariant this PR is trying to establish.
Please keep dictionary-bearing predicates out of remote filter pushdown (or re-check after that pushdown), and add a regression that exercises remote() / Distributed rather than only the local replicated-table plan.
There was a problem hiding this comment.
remote() node is something user references, so I am keeping this out of scope of this PR.
Fallback to local execution when dictionary is referenced in the plan execution. Falls back following queries:
dictGet,dictHas,dictIsInChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Fall back to local execution for
make_distributed_planqueries that call dictionary functions, avoidingDictionary (...) not foundfailures on worker nodes.Workflow [PR]
Sync PR [sync-upstream/pr/121198]
Version info
26.10.1.394-master(included in26.10and later)