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

SNOW-874803: stream rows api blocks the event loop #593

Open
dynamikus opened this issue Jul 24, 2023 · 2 comments
Open

SNOW-874803: stream rows api blocks the event loop #593

dynamikus opened this issue Jul 24, 2023 · 2 comments
Assignees
Labels
enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team

Comments

@dynamikus
Copy link

dynamikus commented Jul 24, 2023

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of NodeJS driver are you using?
    1.6.23

  2. What operating system and processor architecture are you using?
    Windows

  3. What version of NodeJS are you using?
    (node --version and npm --version)
    20.2.0

  4. What are the component versions in the environment (npm list)?

5.Server version:* E.g. 1.90.1
7.24.2
6. What did you do?

I am using the stream rows api, to stream the results back. I have a modest data set of 100K. While data is getting downloaded no other process in the event loop is getting processed. I would assume the culprit is[ process.nextTick()] (https://github.com/snowflakedb/snowflake-connector-nodejs/blob/master/lib/connection/result/row_stream.js#L174) or something related to that.

This is because process.nextTick() is not technically part of the event loop. Instead, the nextTickQueue will be processed after the current operation is completed, regardless of the current phase of the event loop. Basically, any other task that is part of the event loop will get deferred till Snowflake is done getting the data.

  1. What did you expect to see?

I expect streaming data should be a non-blocking event, so it can give a chance to other processes in the event loop to run.

@dynamikus dynamikus added the bug Something isn't working label Jul 24, 2023
@github-actions github-actions bot changed the title stream rows api blocks the event loop SNOW-874803: stream rows api blocks the event loop Jul 24, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage Issue is under initial triage and removed bug Something isn't working labels Jul 25, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jul 25, 2023
@sfc-gh-dszmolka
Copy link
Collaborator

hello and thank you for submitting this issue. it is quite astonishing to me, because looking at the git blame, this code part has been there forever (but at least since it was originally uploaded to Github, 5 years ago).

of course it doesn't mean it has to be like this going forward, so we're going to take a look how the row stream could be reimplemented to play better along with the eventloop.

@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature and removed status-triage Issue is under initial triage labels Jul 25, 2023
@dynamikus
Copy link
Author

Yeah same here, I have been using this sdk for 4+ years now, and never come across a scenario to process something else while waiting for the data to load till last week.

Anyway thank you for looking into this, let me know if you want a code example to replicate it.

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

4 participants