Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3139: Plan Hash Instability in recursive union query #3142

Merged
merged 5 commits into from
Feb 14, 2025

Conversation

alecgrieser
Copy link
Collaborator

This updates the plan hashes for some of the plan operators associated with recursive CTEs. They previously hashed the quantifier directly, which could include things like enum hashes, which are not stable across JVMs. This resulted in multi-server test failures. This updates the plan hash calculations to be based off of the child plans instead of the child quantifiers, which have stable plan hashes.

To test this, I published this change to my maven local repo. I then configured the yaml tester to use that newly published library against my embedded driver, and I validated that the failing tests in recursive-cte.yamsql now passed. In order to make this actually mergeable, though, I needed to update the supported_version on those two tests to !current_version, which means we won't actually get coverage of this until the next release. We could consider adding additional configurations that compare embedded versus external on the same version, which would help cover things like this, but I didn't add that in this PR.

I did update recursive-cte.yamsql with query plans, which made it clearer what plans to look at and felt like good things to have. I've checked in the now necessary metrics files as well for those plans.

This fixes #3139.

This updates the plan hashes for some of the plan operators associated with recursive CTEs. They previously hashed the quantifier directly, which could include things like enum hashes, which are not stable across JVMs. This resulted in multi-server test failures. This updates the plan hash calculations to be based off of the child _plans_ instead of the child _quantifiers_, which have stable plan hashes.

To test this, I published this change to my maven local repo. I then configured the yaml tester to use that newly published library against my embedded driver, and I validated that the failing tests in `recursive-cte.yamsql` now passed. In order to make this actually mergeable, though, I needed to update the `supported_version` on those two tests to `!current_version`, which means we won't actually get coverage of this until the next release. We could consider adding additional configurations that compare embedded versus external on the same version, which would help cover things like this, but I didn't add that in this PR.

I did update `recursive-cte.yamsql` with query plans, which made it clearer what plans to look at and felt like good things to have. I've checked in the now necessary metrics files as well for those plans.

This fixes FoundationDB#3139.
@@ -184,7 +184,7 @@ public int hashCodeWithoutChildren() {

@Override
public int planHash(@Nonnull final PlanHashMode mode) {
return PlanHashable.objectsPlanHash(mode, BASE_HASH, getTempTableReferenceValue());
return PlanHashable.objectsPlanHash(mode, BASE_HASH, getChild());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually use BOTH the reference value and the child. The reference value is safe (to be used for plan hashes; only quantifiers are not).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added back the getTempTableReferenceValue() (and the Boolean isOwningTemplate, which I think was an oversight). I'd thought that that was also unstable, but further local tests seem to suggest I was wrong, so either I was comparing the wrong thing or I was comparing this code against hashing the quantifier by mistake. I've re-done the final test (pushing a build to maven local and running the multi-server tests with two JVMs on the latest code), and the plan hashes were stable.

Copy link

Overall Project 80.17% 🍏

There is no coverage information present for the Files changed

@alecgrieser alecgrieser merged commit 3b7507d into FoundationDB:main Feb 14, 2025
4 checks passed
@alecgrieser alecgrieser deleted the 03139-plan-hash-stability branch February 14, 2025 10:49
@ScottDugas ScottDugas added the bug fix Change that fixes a bug label Feb 14, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plan Hash Instability in recursive union query
3 participants