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

implement keep alive #11

Merged
merged 1 commit into from
Mar 9, 2021
Merged

implement keep alive #11

merged 1 commit into from
Mar 9, 2021

Conversation

dustinfarris
Copy link
Member

@dustinfarris dustinfarris commented Mar 8, 2021

Snowflake enforces a max idle time of 4 hours for authenticated
sessions. Any queries attempted on an idle connection after 4 hours
will error with:

Authentication token has expired.  The user must authenticate again.
SQLSTATE IS: 08001

The idle restriction is configurable for JDBC, but unfortunately not for
ODBC. For ODBC users, Snowflake recommends sending periodic dummy
queries to prevent the session from being idle for more than 4 hours.

This change adds a keep_alive? option to the Connection module. When
true, each worker in the connection pool will send a SELECT 1 query to
Snowflake every 3 hours if no other query has been executed for that
worker. keep_alive? defaults to false so that existing users may
choose to opt in.

The Erlang meck library has been added to support unit testing odbc.

See also Snowflake's FAQ on idle connections:
https://community.snowflake.com/s/article/faq-how-long-can-my-jdbcodbc-connection-remain-idle

Snowflake enforces a max idle time of 4 hours for authenticated
sessions.  Any queries attempted on an idle connection after 4 hours
will error with:

    Authentication token has expired.  The user must authenticate again.
    SQLSTATE IS: 08001

The idle restriction is configurable for JDBC, but unfortunately not for
ODBC.  For ODBC users, Snowflake recommends sending periodic dummy
queries to prevent the session from being idle for more than 4 hours.

This change adds a `keep_alive?` option to the Connection module.  When
true, each worker in the connection pool will send a `SELECT 1` query to
Snowflake every 3 hours if no other query has been executed for that
worker.  `keep_alive?` defaults to `false` so that existing users may
choose to opt in.

The Erlang meck library has been added to support unit testing odbc.

See also Snowflake's FAQ on idle connections:
https://community.snowflake.com/s/article/faq-how-long-can-my-jdbcodbc-connection-remain-idle
@dustinfarris dustinfarris force-pushed the DAPPS-303-keep-alive branch from 0bfc5dc to 99a0f91 Compare March 9, 2021 16:42
@dustinfarris dustinfarris changed the title wip: start keep alive implement keep alive Mar 9, 2021
@dustinfarris dustinfarris marked this pull request as ready for review March 9, 2021 16:46
@Ch4s3
Copy link
Contributor

Ch4s3 commented Mar 9, 2021

This looks great overall. I wonder if we want to use meck to test this vs. mox which the core team supports.

@zbarnes757
Copy link
Contributor

@Ch4s3 I was thinking the same thing. I think mox will likely be better for us in the long run.

@dustinfarris
Copy link
Member Author

dustinfarris commented Mar 9, 2021

I wonder if we want to use meck to test this vs. mox which the core team supports.

I looked at mox initially. From my (limited) reading and experience, it looks like it is intended mainly for Elixir behaviours and not much else, but I could be mis-interpreting. In this case I'm looking to mock an Erlang lib.

fwiw I tried this:

Mox.defmock(Snowflex.MockODBC, for: :odbc)

in test_helpers and that failed to compile:

** (ArgumentError) module :odbc is not a behaviour, please pass a behaviour to :for

@dustinfarris dustinfarris merged commit 4a78e24 into master Mar 9, 2021
@dustinfarris dustinfarris deleted the DAPPS-303-keep-alive branch March 9, 2021 19:36
@dustinfarris
Copy link
Member Author

Thanks for the feedback. Created #12 as a followup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants