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: audit all usages of Query to use iterator pattern #59339

Merged
merged 1 commit into from
Mar 3, 2021

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Jan 23, 2021

Similarly to the previous commit (dbc8676), here we audit all usages of Query
method of the internal executor to take advantage of the iterator API
wherever possible (or switching to Exec or QueryRow).
QueryBuffered has been added to the interface too.

The only place where it would be beneficial to use the iterator pattern
but it is not done currently is for SHOW STATISTICS statement - in
there, we have a panic-catcher which works only on the assumption of not
updating any of the shared state (which the iterator API contradicts).
Refactoring that part is left as a TODO.

Fixes: #48595.

Release justification: low-risk update to existing functionality.

Release note: None

@yuzefovich yuzefovich added the do-not-merge bors won't merge a PR with this label. label Jan 23, 2021
@yuzefovich yuzefovich requested a review from a team January 23, 2021 08:09
@yuzefovich yuzefovich requested a review from a team as a code owner January 23, 2021 08:09
@yuzefovich yuzefovich requested review from pbardea and removed request for a team January 23, 2021 08:09
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich yuzefovich removed request for a team and pbardea January 23, 2021 08:09
@yuzefovich yuzefovich force-pushed the internal-executor-extra branch 9 times, most recently from c97aef6 to d1a5870 Compare January 23, 2021 22:57
@yuzefovich yuzefovich requested a review from a team as a code owner January 23, 2021 22:57
@yuzefovich yuzefovich removed the request for review from a team January 24, 2021 05:16
@yuzefovich yuzefovich force-pushed the internal-executor-extra branch 4 times, most recently from ae5091e to 472e94d Compare January 24, 2021 06:29
@yuzefovich yuzefovich force-pushed the internal-executor-extra branch 5 times, most recently from b28b143 to 6251b7b Compare January 24, 2021 21:15
@yuzefovich yuzefovich force-pushed the internal-executor-extra branch 4 times, most recently from 2baee69 to dafd8f0 Compare March 1, 2021 16:19
@yuzefovich yuzefovich changed the title sql: audit all usages of the internal executor to take advantage of iterator API sql: audit all usages of Query to use iterator pattern Mar 1, 2021
@yuzefovich yuzefovich removed the do-not-merge bors won't merge a PR with this label. label Mar 1, 2021
@yuzefovich yuzefovich requested review from irfansharif, rafiss and otan and removed request for irfansharif and rafiss March 1, 2021 16:22
@yuzefovich
Copy link
Member Author

@irfansharif @otan @rafiss github suggested you as reviewers. Could one of you take a look at this please?

@rafiss rafiss requested a review from RichardJCai March 1, 2021 16:26
@rafiss
Copy link
Collaborator

rafiss commented Mar 1, 2021

CCing @RichardJCai too as it may touch his idea in #60507

@irfansharif
Copy link
Contributor

(Looking at the code areas, I'm definitely not familiar with any of it - so I'll defer elsewhere. Sorry!)

Similarly to the previous commit, here we audit all usages of `Query`
method of the internal executor to take advantage of the iterator API
wherever possible (or switching to `Exec` or `QueryRow`).
`QueryBuffered` has been added to the interface too.

The only place where it would be beneficial to use the iterator pattern
but it is not done currently is for `SHOW STATISTICS` statement - in
there, we have a panic-catcher which works only on the assumption of not
updating any of the shared state (which the iterator API contradicts).
Refactoring that part is left as a TODO.

Release justification: low-risk update to existing functionality.

Release note: None
@yuzefovich yuzefovich removed the request for review from irfansharif March 2, 2021 16:59
Copy link
Contributor

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 22 of 22 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @otan, @rafiss, @RichardJCai, and @yuzefovich)


pkg/ccl/backupccl/backup_planning.go, line 961 at r1 (raw file):

			// Include all tenants.
			// TODO(tbg): make conditional on cluster setting.
			tenantRows, err = p.ExecCfg().InternalExecutor.QueryBuffered(

This could be problematic with many tenants, right?

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.

TFTR!

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @adityamaru, @dt, @otan, @rafiss, and @RichardJCai)


pkg/ccl/backupccl/backup_planning.go, line 961 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

This could be problematic with many tenants, right?

Yeah, possibly, but it didn't seem trivial to refactor, so I'll leave it to Bulk IO friends. cc @dt @adityamaru

@craig
Copy link
Contributor

craig bot commented Mar 2, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Mar 2, 2021

Build failed:

@yuzefovich
Copy link
Member Author

bors r+

@craig craig bot merged commit 4ab29d4 into cockroachdb:master Mar 3, 2021
@craig
Copy link
Contributor

craig bot commented Mar 3, 2021

Build succeeded:

@yuzefovich yuzefovich deleted the internal-executor-extra branch March 3, 2021 03:03
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.

sql: missing memory accounting for internal executor (+crash w/ crdb_internal.jobs)
5 participants