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

Abort leak file descriptor #4021

Closed
2 tasks done
BertholetDamien opened this issue Jun 22, 2019 · 31 comments
Closed
2 tasks done

Abort leak file descriptor #4021

BertholetDamien opened this issue Jun 22, 2019 · 31 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Milestone

Comments

@BertholetDamien
Copy link

BertholetDamien commented Jun 22, 2019

  • Package Name: @azure/storage-blob
  • Package Version: 10.3.0
  • Operating system: Linux Alpine
  • nodejs
    • version: 10.15.3
  • typescript
    • version: 3.2.2

Describe the bug
When we abort the connection of a download on a blockBlobURL, there is a leak of file descriptor because the readable stream body source should be destroy.

To Reproduce
Steps to reproduce the behavior:

  1. Start a simple server.

  2. Check the file descriptor count of your node process with something like :
    lsof | grep socket | grep node | wc -l

  3. Do a ab test on this serveur that will start a download and abort the connection

  4. Check the file descriptor count after.

Some code to help :

    const aborter = Azure.Aborter.timeout(0);
    const blockBlobUrl = Azure.BlockBlobURL.fromContainerURL(this.containerUrl, filePath);
    const downloadBlockBlobResponse = await blockBlobUrl.download(aborter);

    // For test purpose
    setTimeout(() => {
        aborter.abort();
    }, 1000);

Of course, the downloadBlockBlobResponse.readableStreamBody need to be consume.

My actual work around is too destroy the readable stream body source myself :

       aborter.abort();
       // @ts-ignore
       downloadBlockBlobResponse.readableStreamBody.source.destroy();

Expected behavior
The readable stream body source should be destroy if the connection is abort.

I hope this can help !

@kurtzeborn kurtzeborn added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files) labels Jun 24, 2019
@kurtzeborn
Copy link
Member

Thank you for opening this issue! We are routing it to the appropriate team for follow up.

@jeremymeng
Copy link
Member

/cc @XiaoningLiu

@XiaoningLiu XiaoningLiu self-assigned this Jun 26, 2019
@XiaoningLiu XiaoningLiu added enhancement question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jun 26, 2019
@XiaoningLiu
Copy link
Member

XiaoningLiu commented Jun 26, 2019

Thanks for help debugging! What the Aborter.abort() does is to trigger aborter signal into under layer axios HTTP client, which should handle the aborted connection. (readableStreamBody is a readable stream for HTTP response body download stream, based on the connection)

It's surprised to me there will be a fd leak. Also interesting whether what will happen when we wait for longer time to see the fd drops. Still needs investigation.

@BertholetDamien
Copy link
Author

Thank for looking into that.

If I can do anything to help you, don't hesitate.

@XiaoningLiu
Copy link
Member

Thank for looking into that.

If I can do anything to help you, don't hesitate.

Thanks! Aborter instance is passed to under layer @azure/ms-rest-js's axios wrapper. When abort() single triggered, @azure/ms-rest-js will handle the event, and finally trigger abort event to axios. If there is not a leak in @azure/ms-rest-js, then most probably, axios should be responsible for that.

That's my first thoughts, but didn't have time for confirmation yet. You can take a look if have time.

@BertholetDamien
Copy link
Author

Okay, I will check that when I got time !

@kurtzeborn
Copy link
Member

Looks like the question has been addressed here. @BertholetDamien, thanks for reaching out. If you have further questions, please open another issue and we'll get right on it.

@ghost
Copy link

ghost commented Sep 13, 2019

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

@BertholetDamien
Copy link
Author

The problem is not solved and I don't have personnal time to check that deeper.
So for, now, I use the workaround (see the description).

@XiaoningLiu
Copy link
Member

recently released 12.0.0-preview.3 or 10.5.0 deprecates axios and switches to node-fetch, worth a try.

@BertholetDamien
Copy link
Author

Nice to hear ! I will check (one of these day) if this update will fix the issue and report it here.

@BertholetDamien
Copy link
Author

Hi team,

We try the "@azure/storage-blob": "^12.0.1" and the issue is still there.

And my Workaround doesn't work anymore with these version so we had rollback to 10.4.1 with the work around.

Can you tell me if you will be able to investigate ?

Thanks a lot for your time

@jeremymeng jeremymeng reopened this Feb 3, 2020
@XiaoningLiu
Copy link
Member

Hi @BertholetDamien I'll try to take a look when I get time. Besides that, if possible, try to disable keep alive options and see if it works in latest version.

const pipeline = newPipeline(credential, {
      keepAliveOptions: { enable: false }
    });

@BertholetDamien
Copy link
Author

Thanks ! I will check this option when I will have time.

Keep me posted if you look further.

@Petermarcu Petermarcu added the Service Attention Workflow: This issue is responsible by Azure service team. label Jul 14, 2020
@ghost
Copy link

ghost commented Jul 14, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

@XiaoningLiu XiaoningLiu removed the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Jul 15, 2020
@ramya-rao-a ramya-rao-a added feature-request This issue requires a new behavior in the product in order be resolved. and removed enhancement labels Jul 20, 2020
@ramya-rao-a ramya-rao-a added this to the Backlog milestone Jul 20, 2020
@ghost ghost removed the no-recent-activity There has been no recent activity on this issue. label Oct 28, 2020
@jeremymeng
Copy link
Member

Maybe. I don't remember whether v10 dependency is still using axios or not. Either way there might be similar code.

@BertholetDamien
Copy link
Author

@jeremymeng yes, v10 was using axios.
But v12 wasn't and I had the same problem with v12.

@ljian3377 You're seem right, theses related issues look to be the same problem.

For now on, I can't update my sdk version because of that issue. So I'm still in the v10 version.

@ghost ghost added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Oct 28, 2020
@amishra-dev amishra-dev added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 11, 2020
@ljian3377 ljian3377 modified the milestones: Backlog, [2021] February Dec 12, 2020
@ljian3377 ljian3377 removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Dec 12, 2020
@jeremymeng
Copy link
Member

@BertholetDamien we fixed the issue recently in latest versions of @azure/storage-blob v12 and @azure/core-http. Could you please give it a try?

@BertholetDamien
Copy link
Author

It's a really good new! I'm curious, can I have the related commit about that?

I'll be very happy to test, but can you let me somes days? I will give you feedback as soon as I had one.

@jeremymeng
Copy link
Member

@BertholetDamien @azure/core-http fix: #12038

@BertholetDamien
Copy link
Author

Nice! Thank you very much for taking the time to fix this problem.

@ljian3377 ljian3377 added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Feb 10, 2021
@jeremymeng
Copy link
Member

Similar fix has been ported to Azure/ms-rest-js#425. It should fix memory leak issue caused by the abort event handlers for storage v10.

@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Feb 18, 2021
@ghost
Copy link

ghost commented Feb 18, 2021

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@ghost ghost closed this as completed Mar 4, 2021
@BertholetDamien
Copy link
Author

BertholetDamien commented Mar 5, 2021

@jeremymeng

I try the new version last week, and my kubernetes node has just get a lot of issues. So I rollback to the version 10 with my work around for the leak descriptor issue.

Honestly, I don't have time right now to give you a minimal reproductible setup or investigate in any way.

I plan to stay on the v 10 as long as I can and if I need to update one day, I will reopen an issue if the problem occur again with more information.

Thanks a lot for your work team!

@ghost ghost removed the no-recent-activity There has been no recent activity on this issue. label Mar 5, 2021
@jeremymeng
Copy link
Member

@BertholetDamien I am sorry to hear that you hit issues with the new version. Hopefully you could find some time to provide us more details in the future.

@ljian3377
Copy link
Member

@BertholetDamien
Are you experiencing the issue with Aborter or destroy() alone.
I believe in the aborter way, the latest V12 should work as expected, releasing underlying resources. We still need to fix it for the destroy() path.

import { BlobClient } from "@azure/storage-blob";
import { AbortController } from "@azure/abort-controller";

async function main() {
    const aborter = new AbortController();
    const res = await blobClient.download(undefined, undefined, {
      abortSignal: aborter.signal,
    });
    aborter.abort();
}

See #11850 (comment)

@BertholetDamien
Copy link
Author

BertholetDamien commented Mar 10, 2021

@ljian3377
That was with the Aborter. The problem I had with the v12, when I test it day ago, I don't know if it's still related to the same problem (file descriptor leak) or something else. I haven't investigate, because I was in the middle of a big release, I had to manage a lot of others things.
Maybe it's not even the SDK and it was me who made a mistake with my last test (5 days ago). So I don't think investigating this is a good use of your time until I provide more information.

Did you plan to deprecated old versions at some point?

@ljian3377
Copy link
Member

Did you plan to deprecated old versions at some point?

Yes. So we strongly encourage you to migrate to V12.

@BertholetDamien
Copy link
Author

@ljian3377 Thanks for the warning. I will plan that in the futur.
And like I said, I will open an other ticket if needed.
Thanks a lot team!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

8 participants