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

[storage] wrapper stream destroy source when needed #12899

Merged
merged 12 commits into from
Jan 28, 2021

Conversation

ljian3377
Copy link
Member

@ljian3377 ljian3377 commented Dec 15, 2020

Fixes issue in the storage side for #11850

TODO

  • abortSignal integration with core-http
  • changelog

@ghost ghost added the Storage Storage Service (Queues, Blobs, Files) label Dec 15, 2020
@ljian3377 ljian3377 changed the title [storage] Wrapper Stream release source [storage] wrapper stream destroy source when needed Dec 16, 2020
Copy link
Member

@XiaoningLiu XiaoningLiu left a comment

Choose a reason for hiding this comment

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

no objections for this, please check any side effects to destory source stream after source emits error event

@jeremymeng
Copy link
Member

Looking at the changes I am still not sure how this.source would know about any errors happen in the wrapper stream.

@jeremymeng
Copy link
Member

for example, do we need something like below to pass error to the original source stream?

this.on("error", () => this.source.emit("error"));

@ljian3377
Copy link
Member Author

ljian3377 commented Jan 7, 2021

Looking at the changes I am still not sure how this.source would know about any errors happen in the wrapper stream.

@jeremymeng
So far, there are two cases where the wrapper stream will emit error:

  • in the abortHandler(), where we will destroy the source
  • in the sourceErrorOrEndHandler(), since the source has already emitted "error" or "end" event, I think we can count on the source to destroy itself. I thought about manually destroy the source in this case too but I am not sure what should I expect if the source is destroyed multiple times.

I don't think this is helpful. Let the source emit error won't release its resource. Calling this.source.destroy() is more like what we should do.

this.on("error", () => this.source.emit("error"));

I am thinking about

this.on("error", () => this.destroy());

where we will remove all the listeners and destroy the source. But will the source.destroy() work as a no-op if the source has already been destroyed.

@jeremymeng
Copy link
Member

I don't think this is helpful. Let the source emit error won't release its resource

You are right. I meant that we need to do something to close the source when our wrapper is destroyed like in the repro code of #11850.

According to the doc any further calls after destroy() will be no-op: https://nodejs.org/api/stream.html#stream_readable_destroy_error

@ljian3377
Copy link
Member Author

ljian3377 commented Jan 8, 2021

According to the doc any further calls after destroy() will be no-op: https://nodejs.org/api/stream.html#stream_readable_destroy_error

This may not be true untill Node.js V14.

You are right. I meant that we need to do something to close the source when our wrapper is destroyed like in the repro code of #11850.

As we discussed, the _destroy in current implementation does that.
We are good with the changes except that we need to see how this would interact with #12038 where the abortSignal is also dealt with till the download stream is done. As that PR won't be released this month, we have to postpone this one.

@ljian3377 ljian3377 added the Client This issue points to a problem in the data-plane of the library. label Jan 8, 2021
@ljian3377
Copy link
Member Author

/azp run js - storage-blob - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ljian3377
Copy link
Member Author

/azp run js - storage-blob - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jeremymeng jeremymeng left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the fix!

@ljian3377
Copy link
Member Author

/azp run js - storage-blob - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ljian3377 ljian3377 mentioned this pull request Jan 28, 2021
2 tasks
@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run js - [service] - ci

@ljian3377
Copy link
Member Author

/check-enforcer reset

@ljian3377
Copy link
Member Author

/check-enforcer evaluate

@ljian3377 ljian3377 merged commit 3468baa into Azure:master Jan 28, 2021
@ljian3377 ljian3377 deleted the storage/stream-fix branch January 28, 2021 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants