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

Expose CLIENT_SESSION_KEEP_ALIVE as a configuration option similarly to other drivers #847

Open
segfault16 opened this issue Jul 14, 2023 · 6 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

@segfault16
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?

v1.6.22

  1. What operating system and processor architecture are you using?

linux amd64

  1. What version of GO are you using?

1.20.4

5.Server version:* E.g. 1.90.1

  1. What did you do?

Backend service returns 390114: Authentication token has expired. The user must authenticate again after some time after being started. The service uses private key authentication with snowflake db and is intended to serve an API to a webapp. So it's long-running.
I've read about the heartbeat functionality, but it doesn't seem to prevent this error.

  1. What did you expect to see?

  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)

@segfault16 segfault16 added the bug Erroneous or unexpected behaviour label Jul 14, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jul 16, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Jul 16, 2023
@sfc-gh-dszmolka
Copy link
Contributor

hello and thank you for submitting this issue ! also great that you already read upon the keep alive functionality; it is indeed the way to go to refresh the authentication token which by default has a 4-hour lifetime - to refresh it, you need to send keepalives with the driver (or alternatively, any dummy query like SELECT 1 every now and then)

the keepalives are enabled and automatically sent every hour when the parameter CLIENT_SESSION_KEEP_ALIVE is set in the connection parameters per the driver documentation.

you can find a full connection string example at the above documentation section, or if you look into the driver_test.go file, the createDSNWithClientSessionKeepAlive function also has an example how to set this parameter.

hope this helps - if it doesn't, please send a minimal viable reproduction program which when run, exhibits the behaviour of the driver not sending keepalives.

@sfc-gh-dszmolka sfc-gh-dszmolka added question Issue is a usage/other question rather than a bug status-information_needed Additional information is required from the reporter and removed bug Erroneous or unexpected behaviour status-triage Issue is under initial triage labels Jul 16, 2023
@segfault16
Copy link
Author

Hi, testing now with

	t := "true"
	cfg := &sf.Config{
		Account:       sfAccount,
		User:          sfUser,
		Database:      sfDatabase,
		Schema:        sfSchema,
		Warehouse:     sfWarehouse,
		Role:          sfRole,
		Authenticator: sf.AuthTypeJwt,
		PrivateKey:    rsaPrivateKey,
		Params:        map[string]*string{"client_session_keep_alive": &t},
	}

which to be honest looks pretty ugly and is not that obvious when reading the documentation.
Also by the time this error occurred I could've already deployed to production. I'd expect a DB package to behave differently here.

@segfault16
Copy link
Author

segfault16 commented Jul 18, 2023

Confirmed working for > 24 hours now.

How about having this as a separate config option (I hope you agree the Params above is pretty ugly), having this turned on as a default or maybe even providing the config as a func() *sf.Config argument to sf.DSN() to mitigate SF driver having credentials in memory during runtime but still providing a similar experience like other db drivers and being able to open new connections with proper error handling?

@sfc-gh-dszmolka
Copy link
Contributor

okay, that's good to hear the parameter works as intended so now you have a way to keep the long running connection alive.
exposing it as a nice configuration setting also makes sense, and we'll look into that. I'm editing the Issue summary to reflect it.

@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature status-in_progress Issue is worked on by the driver team and removed question Issue is a usage/other question rather than a bug status-information_needed Additional information is required from the reporter labels Jul 19, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka changed the title Handling 390114: Authentication token has expired. The user must authenticate again Expose CLIENT_SESSION_KEEP_ALIVE as a configuration option similarly to other drivers Jul 19, 2023
@segfault16
Copy link
Author

@sfc-gh-anugupta any updates? ETA?

@sfc-gh-dszmolka sfc-gh-dszmolka removed the status-in_progress Issue is worked on by the driver team label Jan 18, 2024
@sfc-gh-dszmolka
Copy link
Contributor

no timeline estimates as of now, but will share if any new information becomes available
(functionality works as of today, request is to expose it in a different way similarly to other drivers)

@snowflakedb snowflakedb deleted a comment from nashier-dmv Mar 5, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label Mar 12, 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

3 participants