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

sql: correctly reset the planner in the copy shim #89112

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

yuzefovich
Copy link
Member

Previously, we forgot to update the txn of the eval context of the planner.

Release note: None

Previously, we forgot to update the txn of the eval context of the
planner.

Release note: None
@yuzefovich yuzefovich requested review from cucaroach and a team September 30, 2022 19:22
@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.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @cucaroach and @yuzefovich)


pkg/sql/copyshim.go line 101 at r1 (raw file):

		p.optPlanningCtx.init(p)
		p.resetPlanner(ctx, txn, stmtTS, p.sessionDataMutatorIterator.sds.Top())
		p.extendedEvalCtx.Context.Txn = txn

Should we be doing this in planner.resetPlanner? It kind of feels like a footgun that we have to remember to do this.

Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @cucaroach and @DrewKimball)


pkg/sql/copyshim.go line 101 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

Should we be doing this in planner.resetPlanner? It kind of feels like a footgun that we have to remember to do this.

This was my original intention too, but when I tried it, things failed in other spots (namely in newInternalPlanner the panic with makeInternalPlanner called with a transaction without timestamps happened), so I opted for this solution. On the main code path the txn is being reset connExecutor.resetEvalCtx after planner.resetPlanner (in connExecutor.resetPlanner), and this commit kinda does things in a similar fashion. Additionally, this copy shim is a test-only utility, so it seems safer to limit the change only to this testing kind since planner.resetPlanner is used in the production code.

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.

Thanks for the explanation. Did you encounter a bug that led you to find this?

:lgtm:

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

@yuzefovich
Copy link
Member Author

I hit it when performing a clean up in #89052. That PR attempts to separate out the shutting down of "flow" infrastructure from closing of the "plan" stuff (currently we have to "close" the latter before cleaning up the former). This bug can be hit when evaluating postqueries, but previously it was hidden because we delayed shutting down the "flow" infrastructure (which correctly unsets the txn in the eval context) until after postqueries complete.

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 30, 2022

Build succeeded:

@craig craig bot merged commit 8e6b81b into cockroachdb:master Sep 30, 2022
@yuzefovich yuzefovich deleted the fix-copy-shim branch September 30, 2022 23:55
@mgartner
Copy link
Collaborator

mgartner commented Oct 4, 2022

Should we backport this, or are we unlikely to encounter it when backporting future PRs to 22.2?

@cucaroach
Copy link
Contributor

copyshim.go will be gone from master soon and then backported to 22.2 for the .1 release so it will solely exist on 22.2.0 branch. I don't see the point of fixing it there.

@yuzefovich
Copy link
Member Author

Furthermore, this is a test-only code with this bug being hidden on 22.2 due to some other code.

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

Successfully merging this pull request may close these issues.

5 participants