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

Close result readers correctly #4592

Merged
merged 1 commit into from
Feb 6, 2019

Conversation

systay
Copy link
Collaborator

@systay systay commented Feb 5, 2019

Signed-off-by: Andres Taylor <antaylor@squareup.com>
@systay systay requested a review from sougou as a code owner February 5, 2019 20:14
func (scw *SplitCloneWorker) getSourceResultReader(ctx context.Context, td *tabletmanagerdatapb.TableDefinition, state StatusWorkerState, chunk chunk, txID int64) (ResultReader, error) {
sourceReaders := make([]ResultReader, len(scw.sourceShards))
var readers []ResultReader
defer func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to be concerned around panics?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're worried about readers being nil: go's range construct treats nil as an empty list. So, there won't be a panic.

Copy link
Member

Choose a reason for hiding this comment

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

I thought the concern was that an uncaught panic might cause the readers to not be closed.

Copy link
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

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

Nvm. I see a nil check in the latest change, which is probably what you were asking for.

@sougou sougou merged commit 634b176 into vitessio:master Feb 6, 2019
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