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

release-24.3: sql: simplify generic query plans #133073

Merged
merged 4 commits into from
Oct 31, 2024

Conversation

mgartner
Copy link
Collaborator

Backport 4/4 commits from #131791.

/cc @cockroachdb/release


sql: do not cache non-reusable plans

Fixes #132963

Release note (bug fix): A bug has been fixed that caused non-reusable
query plans, e.g., plans for DDL and SHOW ... statements, to be cached
and reused in future executions, possibly causing stale results to be
returned. This bug only occurred when plan_cache_mode was set to
auto or force_generic_plan, both of which are not currently the
default settings.

sql: remove legacy planning code path

An optimization code path from before the introduction of generic query
plans has been removed. This code path remained in the codebase to
de-risk the generic query plans backports. It is not needed in future
versions.

Release note: None

sql: remove unused context parameter in reuseMemo

Release note: None

sql: simplify generic query plans

All fully-optimized memos that can be reused without re-optimization are
now stored in PreparedStatement.GenericMemo. Prior to this commit,
some fully-optimized memos were stored in PreparedStatement.BaseMemo.

Release note: None


Release justification: Refactoring that narrowly missed branch-cut.

@mgartner mgartner requested a review from DrewKimball October 21, 2024 15:48
@mgartner mgartner requested a review from a team as a code owner October 21, 2024 15:48
Copy link

blathers-crl bot commented Oct 21, 2024

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Backports should only be created for serious
    issues
    or test-only changes.
  • Backports should not break backwards-compatibility.
  • Backports should change as little code as possible.
  • Backports should not change on-disk formats or node communication protocols.
  • Backports should not add new functionality (except as defined
    here).
  • Backports must not add, edit, or otherwise modify cluster versions; or add version gates.
  • All backports must be reviewed by the owning areas TL. For more information as to how that review should be conducted, please consult the backport
    policy
    .
If your backport adds new functionality, please ensure that the following additional criteria are satisfied:
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters. State changes must be further protected such that nodes running old binaries will not be negatively impacted by the new state (with a mixed version test added).
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.
  • Your backport must be accompanied by a post to the appropriate Slack
    channel (#db-backports-point-releases or #db-backports-XX-X-release) for awareness and discussion.

Also, please add a brief release justification to the body of your PR to justify this
backport.

@blathers-crl blathers-crl bot added the backport Label PR's that are backports to older release branches label Oct 21, 2024
@mgartner mgartner requested a review from a team October 21, 2024 15:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mgartner)

Fixes cockroachdb#132963

Release note (bug fix): A bug has been fixed that caused non-reusable
query plans, e.g., plans for DDL and `SHOW ...` statements, to be cached
and reused in future executions, possibly causing stale results to be
returned. This bug only occurred when `plan_cache_mode` was set to
`auto` or `force_generic_plan`, both of which are not currently the
default settings.
An optimization code path from before the introduction of generic query
plans has been removed. This code path remained in the codebase to
de-risk the generic query plans backports. It is not needed in future
versions.

Release note: None
All fully-optimized memos that can be reused without re-optimization are
now stored in `PreparedStatement.GenericMemo`. Prior to this commit,
some fully-optimized memos were stored in `PreparedStatement.BaseMemo`.

Release note: None
@mgartner mgartner force-pushed the backport24.3-131791 branch from 06eb528 to 602574c Compare October 30, 2024 16:35
@mgartner mgartner merged commit f7dfc36 into cockroachdb:release-24.3 Oct 31, 2024
20 of 21 checks passed
@mgartner mgartner deleted the backport24.3-131791 branch October 31, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Label PR's that are backports to older release branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants