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

Starting an query in AsyncMode and then preventing pooling on the connection cancels the async query #1077

Open
john-skyward-solutions opened this issue Dec 31, 2024 · 3 comments
Assignees
Labels
question Issue is a usage/other question rather than a bug status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage

Comments

@john-skyward-solutions
Copy link

We've found that starting an async query and then evicting the connection leads to session, and the queries still running on that session, to be cancelled.

I understand why that makes sense in a synchronous world, but in an async world where someone has deliberately started a query in async mode to leave it running it makes little sense.

Is there a way we can either force a new session to begin on the existing open connection after the async mode is started OR evict the connection from the pool in such a way that it does not stop async queries and it's transactions it has open?

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

  1. What version of .NET driver are you using?
    4.2.0

  2. What operating system and processor architecture are you using?
    All of Windows x64 / macOS silicon / Linux x64

  3. What version of .NET framework are you using?
    dotnet 8.0

  4. What did you do?

`using var conn = await new SnowflakeDbConnection("");
conn.Open();
conn.PreventPooling();

var cmd = conn.CreateSnowflakeDbCommand();
cmd.CommandText = "<async query that takes over 5 minutes>";
var queryId = await cmd.ExecuteAsyncInAsyncMode(default);

Console.WriteLine("QueryID started in async mode: {0}", queryId);`

5 minutes after running the above the query will be cancelled.

  1. What did you expect to see?
    The query should continue to execute until completion.
@john-skyward-solutions john-skyward-solutions changed the title Starting an query in AsyncMode and then evicting the connection pool cancels the async query Starting an query in AsyncMode and then preventing pooling on the connection cancels the async query Dec 31, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jan 2, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka added question Issue is a usage/other question rather than a bug and removed bug labels Jan 2, 2025
@sfc-gh-dszmolka
Copy link
Contributor

hi - Happy New Year :)

The behaviour you described -at the first superficial glance- does not seem to be related to this library, but the Snowflake backend itself. Especially the 5 minutes you mentioned is suspicious.

Please see the documentation for ABORT_DETACHED_QUERY - isn't this what we're seeing here? Can you please verify if the parameter is set to FALSE in case in these queries? If it's TRUE then it's expected to see the behaviour you're reporting, regardless of programming language or client driver type.

@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage Issue is under initial triage status-information_needed Additional information is required from the reporter labels Jan 2, 2025
@john-skyward-solutions
Copy link
Author

john-skyward-solutions commented Jan 13, 2025

Yes we set ABORT_DETACHED_QUERY to FALSE before all Async Queries because we run into the cancelled issue for longer running queries. This is why I was so susprised to see this behaviour when preventing the connection to be pooled, because we already set it to false.

The below screenshot is every query in a single session, where we set abort detached query to false and then run our async query after that. You'll see that it still fails.

image

When a connection is removed from the pool, is the session aborted or similar?

@sfc-gh-dszmolka
Copy link
Contributor

yes connection Close() (and Dispose() too) actively closed the underlying Snowflake Session when it's called.

it would be interesting to see the queryId of one of the failed queries but i'm almost sure the Snowflake engine (so not this library in which the issue was filed) aborts it due to being disconnected. Can you share at least one of them ?

speaking about the libraries; it would be interestin to run the same query with another Snowflake driver which supports async mode (JDBC driver, Python driver, now Node.js driver too i believe) and compare the behaviour. I would assume it's the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue is a usage/other question rather than a bug status-information_needed Additional information is required from the reporter status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

2 participants