Skip to content

Stabilize hash codes used by the planner - #4263

Merged
robert-brunel merged 1 commit into
FoundationDB:mainfrom
robert-brunel:hash-stability
Jun 12, 2026
Merged

robert-brunel merged 1 commit into
FoundationDB:mainfrom
robert-brunel:hash-stability

Conversation

@robert-brunel

Copy link
Copy Markdown
Contributor

This change fixes some unstable hash codes that can affect the planner; in particular, uses of Enum.hashCode() and byte[].hashCode(). Those inherit the identity-based hashCode() method from Object and can therefore return different values on every JVM run for the same logical content. To stabilize them, we compute the hashes from enum.name() or PlanHashable.objectPlanHash() instead.

  • The hashes of ListComparison, ParameterComparisonBase, and LitervalValue.hashCodeWithoutChildren() flow into AbstractValue.semanticHashCode(), which is used as the tie-breaker in RewritingCostModel.

  • The hashes of Ordering.Binding and PredicateMultiMap.MappingKey can affect the bucket layout for maps keyed on Binding or MappingKey, and thus the planning iteration order.

@robert-brunel robert-brunel self-assigned this Jun 5, 2026
@robert-brunel robert-brunel added the bug fix Change that fixes a bug label Jun 5, 2026
@robert-brunel
robert-brunel requested a review from normen662 June 5, 2026 15:41
@robert-brunel robert-brunel added the Run mixed-mode Label to add to Pull Requests to have it run mixed mode tests label Jun 12, 2026
This change fixes some unstable hash codes that can affect the planner; in particular, uses of `Enum.hashCode()` and `byte[].hashCode()`. Those inherit the identity-based `hashCode()` method from `Object` and can therefore return different values on every JVM run for the same logical content. To stabilize them, we compute the hashes from `enum.name()` or `PlanHashable.objectPlanHash()` instead.

* The hashes of `ListComparison`, `ParameterComparisonBase`, and `LitervalValue.hashCodeWithoutChildren()` flow into `AbstractValue.semanticHashCode()`, which is used as the tie-breaker in `RewritingCostModel`.

* The hashes of `Ordering.Binding` and `PredicateMultiMap.MappingKey` can affect the bucket layout for maps keyed on `Binding` or `MappingKey`, and thus the planning iteration order.
@robert-brunel
robert-brunel merged commit ee2ce79 into FoundationDB:main Jun 12, 2026
22 checks passed
@robert-brunel
robert-brunel deleted the hash-stability branch June 12, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Change that fixes a bug Run mixed-mode Label to add to Pull Requests to have it run mixed mode tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants