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

distsql: restore EvalCtx.Mon on the flow cleanup #69483

Merged
merged 2 commits into from Aug 28, 2021

Conversation

yuzefovich
Copy link
Member

distsql: restore EvalCtx.Mon on the flow cleanup

In setupFlow, if we're setting up a flow on the gateway, we're using
LocalState to save on deserialization of some state. Notably, we pass
the eval context that we used during the physical planning. That eval
context can be mutated (in particular, we're updating its Mon field to
the "flow" memory monitor), and previously this could cause issues when
automatically retrying stats collection jobs (possibly there could be
other issues).

This commit introduces a callback to restore the local eval context to
its original state which is done on the flow cleanup.

Fixes: #68670.
Fixes: #67113.

Release note (bug fix): Previously, table stats collection issued via
ANALYZE statement or via CREATE STATISTICS statement without
specifying AS OF SYSTEM TIME option could run into
flow: memory budget exceeded, and this has been fixed.

Release justification: fix to a long standing bug.

distsql: fix cleaning up resources in an error case in setupFlow

Release note: None

Release justification: low-risk improvement to resources' cleanup in an
edge case.

@yuzefovich yuzefovich requested review from rytaft and a team August 27, 2021 18:21
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks! This looks like a clean solution.

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

In `setupFlow`, if we're setting up a flow on the gateway, we're using
`LocalState` to save on deserialization of some state. Notably, we pass
the eval context that we used during the physical planning. That eval
context can be mutated (in particular, we're updating its `Mon` field to
the "flow" memory monitor), and previously this could cause issues when
automatically retrying stats collection jobs (possibly there could be
other issues).

This commit introduces a callback to restore the local eval context to
its original state which is done on the flow cleanup.

Release note (bug fix): Previously, table stats collection issued via
`ANALYZE` statement or via `CREATE STATISTICS` statement without
specifying `AS OF SYSTEM TIME` option could run into
`flow: memory budget exceeded`, and this has been fixed.

Release justification: fix to a long standing bug.
Release note: None

Release justification: low-risk improvement to resources' cleanup in an
edge case.
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @rytaft)

@yuzefovich
Copy link
Member Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 28, 2021

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants