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-1276398: OpenAsync does not throw an exception in case of timeout #900

Closed
vc-74 opened this issue Mar 27, 2024 · 14 comments
Closed

SNOW-1276398: OpenAsync does not throw an exception in case of timeout #900

vc-74 opened this issue Mar 27, 2024 · 14 comments
Assignees
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@vc-74
Copy link

vc-74 commented Mar 27, 2024

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

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

  3. What version of .NET framework are you using?
    .net8

  4. What did you do?
    In the connection string, if a proxy is specified but cannot be reached, OpenAsync times out (as expected) but no exception is thrown resulting in a connection which State is Closed.

string connectionString = "...;useproxy=true;proxy;proxyhost=unreachable;proxyport=4000";
using SnowflakeDbConnection connection = new(connectionString);
await connection.OpenAsync().ConfigureAwait(false);

// connection is Closed and no exception has been thrown
  1. What did you expect to see?

    An exception should be raised in case the connection cannot be opened.

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

    Not relevant.

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

@vc-74 vc-74 added the bug label Mar 27, 2024
@github-actions github-actions bot changed the title OpenAsync does not throw an exception in case of timeout SNOW-1276398: OpenAsync does not throw an exception in case of timeout Mar 27, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Mar 27, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Mar 27, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hi and thank you for raising this with us. So I'm trying to reproduce the problem using .NET Core 6.0 (which is supported by the driver) and Snowflake.Data v3.0.0 and this repro program:

using System.Data.Common;
using Snowflake.Data.Client;

class Program
{
    static async Task Main(string[] args)
    {
        string connectionString = "account=myaccount.eu-central-1; " +
                               " user=admin; password=password; role=ACCOUNTADMIN;" +
                               " DB=TEST_DB; warehouse=COMPUTE_WH;" +
                               " useproxy=true;proxyhost=no.such.pro.xy;proxyport=8080";
        try
        {
            await ConnectToSnowflakeAsync(connectionString);
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error connecting to Snowflake: {ex.Message}");
        }
    }

    static async Task ConnectToSnowflakeAsync(string connectionString)
    {
        using (var connection = new SnowflakeDbConnection())
        {
            connection.ConnectionString = connectionString;

            await connection.OpenAsync().ConfigureAwait(false);

            Console.WriteLine("Connected to Snowflake!");

            await ExecuteQueryAsync(connection, "SELECT current_timestamp()");

            await connection.CloseAsync();
        }
    }

    static async Task ExecuteQueryAsync(DbConnection connection, string query)
    {
        using (var command = connection.CreateCommand())
        {
            command.CommandText = query;

            using (var reader = await command.ExecuteReaderAsync())
            {
                while (await reader.ReadAsync())
                {
                    Console.WriteLine($"Current Timestamp: {reader[0]}");
                }
            }
        }
    }
}

and what I'm seeing after running the program, that it gets hung for ~1.5 minutes, then bails out with

Connected to Snowflake!
Error connecting to Snowflake: Error: Executing command on a non-opened connection. SqlState: , VendorCode: 270059, QueryId:

so I could not get to the 'no exception is thrown' ; i'm getting an error after all. Without the non-existing proxy part, the query is successfully run.

if you're seeing something different, could you please provide us with a minimal viable and runnable code which when run, leads to the issue you're experiencing?

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-information_needed Additional information is required from the reporter label Mar 27, 2024
@vc-74
Copy link
Author

vc-74 commented Mar 27, 2024

so I could not get to the 'no exception is thrown' ; i'm getting an error after all. Without the non-existing proxy part, the query is successfully run.

You actually did, the exception is thrown by ExecuteQueryAsync, not OpenAsync. You did not include the stack trace but it's probably what it says. I would expect OpenAsync to throw the exception instead.

@sfc-gh-dszmolka
Copy link
Contributor

ah - you're right. Got you now. We'll take a look - thanks for drawing our attention to this one !

@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage status-information_needed Additional information is required from the reporter labels Mar 27, 2024
@sfc-gh-erojaslizano sfc-gh-erojaslizano self-assigned this Apr 5, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-in_progress Issue is worked on by the driver team label Apr 9, 2024
@vc-74
Copy link
Author

vc-74 commented Apr 16, 2024

@sfc-gh-dszmolka Hi, any ETA for the resolution of this issue?
Thanks

@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Apr 16, 2024

hey - no fixed ETA known at this moment but i'm syncing internally on this one and will update this thread once I got any estimated delivery. (to set the expectations: the very earliest possible is at the end of this month with the April release cycle, if we fall outside of that, then in the May release cycle)

will post the further details once known - thank you for bearing with us !

@vc-74
Copy link
Author

vc-74 commented Apr 16, 2024

Thanks.
I have a related question: does the connector only take the specified proxy parameters into account, or does it also take the user/system configured proxy into account?

@sfc-gh-dszmolka
Copy link
Contributor

the supported way of specifying the proxy is to use USEPROXY & co. as described in the README, specified in the connection string.

I never tested with the system-wide envvars like HTTP_PROXY / HTTPS_PROXY so it might or might not work, need to test it. Specifying the proxy as .pac file, should not work (for any of the Snowflake drivers)

@vc-74
Copy link
Author

vc-74 commented Apr 16, 2024

I don't think these environment variables are taken into account but it seems like even when I specify a proxy manually, my WinInet configuration is used.

@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented Apr 17, 2024

if you wish to discuss this second topic (on the proxy) further or even suspect there is a bug, could you please raise a separate Issue for it ? Seems a bit unrelated to the original issue which revolves around how OpenAsync behaves and allows dependent queries to proceed (and surely fail) instead of failing fast.

@vc-74
Copy link
Author

vc-74 commented Apr 17, 2024

You're right, thanks

@mbfis
Copy link

mbfis commented Jul 16, 2024

We also got this issue and can't debug it, since we can't figure out why the connection failed to open... We do get exception when trying to execute a query, but that one is expected (trying to run a query on a closed connection). Has this been addressed so far or is this still an open issue?

@sfc-gh-dszmolka
Copy link
Contributor

hi @mbfis , folks, yes indeed this is still an open issue and at this moment unfortunately I don't have a timeline for fix implementation; only that there's someone from the team working on it. As with every other issue in every other Snowflake driver repository, I'm updating this one as well as soon as there is any new information.

To troubleshoot a particular connectivity issue, I can give it a stab if you can please open a new Issue here (to keep things consistent; because this Issue is tracking the behavour of OpenAsync) - or if you're not comfortable sharing connection details, logs here, then please open a case with Snowflake Support. to work 1:1 with a support engineer. Thank 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 Aug 2, 2024
@sfc-gh-dszmolka
Copy link
Contributor

PR under review #999

@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 Aug 6, 2024
@sfc-gh-dszmolka
Copy link
Contributor

released with v4.1.0 of the Snowflake .NET driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

6 participants