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

colexec: add more redundancy to releasing disk resources #81562

Merged
merged 1 commit into from
May 20, 2022

Conversation

yuzefovich
Copy link
Member

As a couple of recently-found issues showed, making sure that all disk
resources are released can be tricky since disk-backed operators can
form large graphs with multiple external operators supporting a single
operation. This commit makes the release of disk resources more
bullet-proof by auditing all users of the vectorized disk queues to make
sure they are added to OpWithMetaInfo.ToClose which are closed on the
flow cleanup. Since Close can be safely called multiple times, it adds
some redundancy, leaning on the side of caution.

In particular, the following changes are made:

  • external distinct and external hash aggregators are explicitly added
    to ToClose slice. They should already be now closed by the
    diskSpillerBase, but it doesn't hurt closing them explicitly.
  • window aggregator operator has been refactored so that it doesn't
    throw an error in its Close method - with the previous version it was
    possible to panic during the Close execution and possibly leak some
    resources.
  • signatures of the constructor methods have been adjusted to return
    ClosableOperator to make the need for closing be more explicit.
  • each router output is now a Closer and the consumer of each output
    is now resposible for closing it. Again, I'm pretty sure that each
    output will have been closed by that time the consumer explicitly tries
    to close the output, yet there is no harm in closing it twice.

An additional minor cleanup is the removal of the usage of an embedded
context in a couple Close implementations given that the function
takes it as an argument.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

As a couple of recently-found issues showed, making sure that all disk
resources are released can be tricky since disk-backed operators can
form large graphs with multiple external operators supporting a single
operation. This commit makes the release of disk resources more
bullet-proof by auditing all users of the vectorized disk queues to make
sure they are added to `OpWithMetaInfo.ToClose` which are closed on the
flow cleanup. Since `Close` can be safely called multiple times, it adds
some redundancy, leaning on the side of caution.

In particular, the following changes are made:
- external distinct and external hash aggregators are explicitly added
to `ToClose` slice. They should already be now closed by the
`diskSpillerBase`, but it doesn't hurt closing them explicitly.
- window aggregator operator has been refactored so that it doesn't
throw an error in its `Close` method - with the previous version it was
possible to panic during the `Close` execution and possibly leak some
resources.
- signatures of the constructor methods have been adjusted to return
`ClosableOperator` to make the need for closing be more explicit.
- each router output is now a `Closer` and the consumer of each output
is now resposible for closing it. Again, I'm pretty sure that each
output will have been closed by that time the consumer explicitly tries
to close the output, yet there is no harm in closing it twice.

An additional minor cleanup is the removal of the usage of an embedded
context in a couple `Close` implementations given that the function
takes it as an argument.

Release note: None
@yuzefovich yuzefovich requested review from michae2, cucaroach and a team May 20, 2022 02:16
@yuzefovich yuzefovich marked this pull request as ready for review May 20, 2022 02:16
Copy link
Contributor

@cucaroach cucaroach left a comment

Choose a reason for hiding this comment

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

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

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:

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

@yuzefovich
Copy link
Member Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented May 20, 2022

Build succeeded:

@craig craig bot merged commit 781b16b into cockroachdb:master May 20, 2022
@yuzefovich yuzefovich deleted the disk-queues branch May 20, 2022 19:12
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.

4 participants