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-21.2: colflow: release disk resources in hash router in all cases #81555

Merged
merged 1 commit into from
May 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pkg/sql/colflow/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,21 @@ func (o *routerOutputOp) Next() coldata.Batch {
o.nextErrorLocked(err)
}
}
// This is the last batch. closeLocked will set done to protect against
// further calls to Next since this is allowed by the interface as well as
// cleaning up and releasing possible disk infrastructure.
// This is the last batch. closeLocked will set the state of the output
// to draining to protect against further calls to Next since this is
// allowed by the interface as well as cleaning up and releasing
// possible disk infrastructure.
o.closeLocked(o.Ctx)
}
return b
}

func (o *routerOutputOp) DrainMeta() []execinfrapb.ProducerMetadata {
o.mu.Lock()
o.mu.state = routerOutputOpDraining
o.maybeUnblockLocked()
// The call to DrainMeta() indicates that the caller will no longer need any
// more data from this output, so we can close it.
o.closeLocked(o.Ctx)
o.mu.Unlock()
return o.drainCoordinator.drainMeta()
}
Expand All @@ -282,6 +285,8 @@ func (o *routerOutputOp) initWithHashRouter(r *HashRouter) {
o.drainCoordinator = r
}

// closeLocked sets the state of the output to 'draining' as well as releases
// possible disk infrastructure. It is safe to be called multiple times.
func (o *routerOutputOp) closeLocked(ctx context.Context) {
o.mu.state = routerOutputOpDraining
if err := o.mu.data.Close(ctx); err != nil {
Expand Down