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

Need to retry result request for get query result by qid #923

Closed
shanhe-fullstory opened this issue Oct 10, 2023 · 8 comments
Closed

Need to retry result request for get query result by qid #923

shanhe-fullstory opened this issue Oct 10, 2023 · 8 comments
Assignees
Labels
bug Erroneous or unexpected behaviour status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector.

Comments

@shanhe-fullstory
Copy link

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

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

  2. What operating system and processor architecture are you using?
    Linux/x86_64 MacOS/arm64

  3. What version of GO are you using?
    go1.19.1

4.Server version:* E.g. 1.90.1
7.35.1

  1. What did you do?
ctx = gosnowflake.WithFetchResultByID(ctx, queryId)
rows, err := s.db.QueryContext(ctx, "")
  1. What did you expect to see?
    It will return no error and no result after about 45 seconds.
    Note that the similar issue for async query is fixed in SNOW-782588: Retry result request for async query if still in progress #824
    But still need to fix rowsForRunningQuery in monitoring.go to check the resp.Code.
    It is possible for resp.Code to be queryInProgressAsyncCode after blocking for 45 seconds.

  2. Can you set logging to DEBUG and collect the logs?

    https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

  3. What is your Snowflake account identifier, if any? (Optional)

@shanhe-fullstory shanhe-fullstory added the bug Erroneous or unexpected behaviour label Oct 10, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Oct 11, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Oct 11, 2023
@sfc-gh-dszmolka
Copy link
Contributor

hi and thank you for raising this issue ! we'll take a look

@sfc-gh-dszmolka sfc-gh-dszmolka added status-in_progress Issue is worked on by the driver team and removed status-triage Issue is under initial triage labels Oct 16, 2023
@sfc-gh-dszmolka
Copy link
Contributor

my colleagues are looking into the issue and could very well reproduce in async.go

respd.Code: 333334
respd.Message: Asynchronous execution in progress. Use provided query id to perform query monitoring and management."

but even with additional logging for rowsForRunningQuery in monitoring.go the long running (>45s) query produced

resp.Code: , Message: , Success: true

and they could not get to resp.Code: 333334.

Do (any of) you perhaps know a reliable way to reproduce getting this response queryInProgressAsyncCode in rowsForRunningQuery? That would be a great help in fixing this issue and validating the fix. Thank you in advance!

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-information_needed Additional information is required from the reporter label Jan 5, 2024
@shanhe-fullstory
Copy link
Author

shanhe-fullstory commented Jan 5, 2024

If we look it at the high level, do this:

  1. Submit a query of sleeping for 70 seconds, and get the query id.
  2. Use WithFetchResultByID and try to get the rows.
  3. It will return prematurely at around 45 seconds without any result (should be a string saying has slept x seconds) and no error.
    The expected behavior is either it waits until the 70 seconds has passed or returns prematurely but with some error.

Right now, I am walking around by checking for no result and no error, and do retry in my application.

So do not bog down by the "check the resp.Code", I might be wrong. But the high level behavior needs to be fixed.

@shanhe-fullstory
Copy link
Author

I just ran again, If I place a breakpoint at line 237 in monitoring.go,

func (sc *snowflakeConn) rowsForRunningQuery(
	ctx context.Context, qid string,
	rows *snowflakeRows) error {
	resultPath := fmt.Sprintf(urlQueriesResultFmt, qid)
	resp, err := sc.getQueryResultResp(ctx, resultPath)

After 45 seconds, the resp.Code is 333334 and Success is true.
If we retry, after the query finishes, the resp.Code is "" and Success is true.

@sfc-gh-dszmolka
Copy link
Contributor

this is excellent, thank you so much, should be very helpful for the team !

@sfc-gh-dszmolka sfc-gh-dszmolka removed the status-information_needed Additional information is required from the reporter label Jan 6, 2024
@sfc-gh-dszmolka
Copy link
Contributor

PR review is in progress under #1021 but if you wish, you can already check out the fix branch https://github.com/snowflakedb/gosnowflake/tree/705-WithFetchResultByID and see if it works for you

@sfc-gh-dszmolka sfc-gh-dszmolka added status-pr_pending_merge A PR is made and is under review and removed status-in_progress Issue is worked on by the driver team labels Jan 9, 2024
@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Jan 16, 2024

PR has been merged and is now available to install from main. I'll need to confirm if it will be available with 1.7.2 (January) or only the next (February) release.

edit: February it is (as it hit main only after January's release was cut)

@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-pr_pending_merge A PR is made and is under review labels Jan 22, 2024
@sfc-gh-dszmolka
Copy link
Contributor

fix released with gosnowflake 1.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Erroneous or unexpected behaviour status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector.
Projects
None yet
Development

No branches or pull requests

3 participants