Repository navigation
Keep the identity of a set in the cache key of an expression - #132104
Conversation
The cache key of an expression is written by `ActionsDAG::serialize` with `for_cache_key`, which leaves out the names the plan build chose, and `isConstantValueInCacheKey` leaves out the value of a set. The set was told apart only by its `__set_<hash>` name, so `v IN (1, 2, 3)` and `v IN (5, 6, 7)` computed in an expression got one key, and automatic parallel replicas decided one query from the statistics collected for the other. Write the set: `serializeConstant` writes only its hash, as `Node::updateHash` keeps it for the same reason. A filter was not affected, because its predicate is keyed through `getOutputIdentity`. Split out of #125687. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [6379111] Summary: ✅
AI ReviewSummaryPR #132104, reviewed at Final VerdictStatus: ✅ Approve |
The fix and its test `05396_autopr_cache_key_set_identity` are now in #132104, which fixes it on master independently of this branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 22 s compile time in total, 7 of them have a recent master baseline. |
Cherry pick #132104 to 26.10: Keep the identity of a set in the cache key of an expression
Backport #132104 to 26.10: Keep the identity of a set in the cache key of an expression
Changelog category (leave one):
Related: #125687
Related: #116781
Related: #126148
The statistics of automatic parallel replicas are keyed by the plan, and the key of an expression is written by
ActionsDAG::serializewithfor_cache_key. That leaves out the names the plan build chose, andisConstantValueInCacheKeyleaves out the value of a set. The__set_<hash>name was the only thing telling two sets apart. Without it,v IN (1, 2, 3)andv IN (5, 6, 7)computed in an expression got the same key, so one query was decided from statistics collected for the other.The fix writes the set into the cache key again.
serializeConstantwrites only the set's hash, which is the same thingNode::updateHashkeeps for this reason. A filter is not affected, because its predicate is keyed throughgetOutputIdentity.The new test
05813_autopr_cache_key_set_identityrunsIN (1, 2, 3), thenIN (5, 6, 7), thenIN (1, 2, 3)again. It checks that the second query reportsAutoParallelReplicasNoStatisticsinstead of reusing the first query's statistics. The test fails on current master (10 of 10 runs on a master CI binary) and passes with the fix.Split out of #125687.
Workflow [PR]
Sync PR [sync-upstream/pr/132104]
Version info
26.11.1.2591-master(included in26.11and later)26.10.6.10