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

NSFS | Add checks for request/response aborted in namespace_fs read_object_stream() #6955

Merged
merged 1 commit into from
May 11, 2022

Conversation

romayalon
Copy link
Contributor

Signed-off-by: Romy [email protected]

Explain the changes

  1. Object_sdk - Added an abort controller property and added 2 functions:
    1.1. setup_abort_controller() - setup event listeners on the req/res that will call abort() of the abort_controller.
    1.2. throw_if_aborted() - will check if the abort_controller got the aborted signal and will throw error when true.
  2. S3_get_object -
    2.1. Called setup_abort_controller() in order to hang the event listeners on each get_object request/response.
    2.2. Removed the previous event listeners code.
  3. Namespace FS -
    3.1. Added a call to object_sdk.throw_if_aborted() after each await in read_object_stream(). (see Note)
    3.2. Passed object_sdk.abort_controller.signal parameter to wait_finished() and to wait_drain().

NOTE -
The whole purpose of this new abort_controller functionality was to fix the following situation -

  1. A Client sends s3_get_object request, NooBaa is writing a buffer to the response, and the client reads it very slowly.
  2. NooBaa in the meantime reads the next data from the fs and holds a new buffer, but NooBaa is not yet writing it to the socket and is awaiting for wait_drain() (because the client reads the data very slowly).
  3. The user calls abort on the request, and the first buffer is released.
  4. NooBaa still awaits on wait_drain() and therefore still holding the second buffer.

Issues: Fixed #xxx / Gap #xxx

  1. Fixed #HPO 659: Mix read/write with md5 checking halts all I/O on all metalLB IP's and does not recover unless noobaa pod restart #6934 hopefully

Testing Instructions:

  • Doc added/updated
  • Tests added

@romayalon romayalon force-pushed the romy-fix-get-object-nsfs branch 3 times, most recently from 37befc4 to 3aca1e9 Compare May 9, 2022 14:30
src/test/unit_tests/test_namespace_fs.js Outdated Show resolved Hide resolved
src/endpoint/s3/ops/s3_get_object.js Outdated Show resolved Hide resolved
src/sdk/object_sdk.js Show resolved Hide resolved
src/sdk/namespace_fs.js Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Show resolved Hide resolved
@romayalon romayalon force-pushed the romy-fix-get-object-nsfs branch from 75540b0 to a6543fa Compare May 9, 2022 15:58
@pull-request-size pull-request-size bot added size/L and removed size/M labels May 9, 2022
@romayalon romayalon force-pushed the romy-fix-get-object-nsfs branch from 92063c0 to 3698f73 Compare May 9, 2022 16:39
@romayalon romayalon requested a review from guymguym May 9, 2022 17:06
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/object_sdk.js Outdated Show resolved Hide resolved
@romayalon romayalon force-pushed the romy-fix-get-object-nsfs branch from bc6df68 to d47c6cb Compare May 9, 2022 19:28
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

another round of comments. apologies for making it iterative.

src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Show resolved Hide resolved
src/sdk/namespace_fs.js Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/object_sdk.js Outdated Show resolved Hide resolved
src/endpoint/s3/ops/s3_get_object.js Outdated Show resolved Hide resolved
@romayalon romayalon force-pushed the romy-fix-get-object-nsfs branch 2 times, most recently from 5e80ebe to 2bf3eab Compare May 10, 2022 12:28
src/core/nsfs.js Outdated Show resolved Hide resolved
src/sdk/namespace_fs.js Outdated Show resolved Hide resolved
src/sdk/object_sdk.js Outdated Show resolved Hide resolved
Comment on lines 85 to 104
req.once('aborted', () => {
dbg.log0('request aborted', req.url);
this.abort_controller.abort();
});
Copy link
Member

Choose a reason for hiding this comment

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

So I just noticed that the aborted event is being deprecated since nodejs 16 (we are still on 14).
https://nodejs.org/dist/latest-v16.x/docs/api/http.html#event-aborted
And the docs recommend listening for the close event. LOL.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like we need to do this:

        req.once('close', () => {
            if (req.destroyed) {
                dbg.log0('request aborted', req.url);
                this.abort_controller.abort(new Error('request aborted ' + req.url));
            }
        });

Copy link
Member

Choose a reason for hiding this comment

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

Ok, so this is a gap for moving to node 16, because on node 14 we can't check the req.destroyed state yet.

FYI @liranmauda and @nimrod-becker - we need to track this so that once we switch to node 16 we make sure to include this fix, which @romayalon left as a comment in the code.

@guymguym
Copy link
Member

@romayalon I resolved the previous comments, but the deprecation of the abort event on the request is probably best to fix...

@romayalon romayalon force-pushed the romy-fix-get-object-nsfs branch from 77f4403 to 777c722 Compare May 10, 2022 16:00
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

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

Great work @romayalon. Super artistic and accurate as usual! Godspeed.

@romayalon romayalon merged commit 50eb16c into noobaa:master May 11, 2022
@romayalon
Copy link
Contributor Author

@guymguym Thank you for your great help and profound code review!

@dannyzaken dannyzaken mentioned this pull request May 18, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants