databricks-sql-go icon indicating copy to clipboard operation
databricks-sql-go copied to clipboard

Avoid session idle timeouts

Open andrefurlan-db opened this issue 2 years ago • 5 comments

Sessions time out. And a connection is associated with a session. If the user does not set max connection idle timeout, it is possible that they'll get errors on session timeout.

We need to either have a heartbeat, or figure out a way to invalidate the session and create a new one. Or as a last resort gracefully handle the error.

andrefurlan-db avatar Dec 13 '22 21:12 andrefurlan-db

Any updates on this one please?

farhank3389 avatar May 19 '23 11:05 farhank3389

Sorry for the delay. There were many discussions on how to deal with this and heartbeats have many drawbacks. SQL Warehouses now have a 8 hour session idle timeout, so this should not be a real issue. Is the concern now primarily related to clusters?

andrefurlan-db avatar May 31 '23 21:05 andrefurlan-db

In my case, I have a web app that works with DataBricks and was wondering what would be the best way to handle session timeouts without restarting the server

databricks: execution error: failed to execute query: Invalid SessionHandle

cghiban avatar Jun 01 '23 15:06 cghiban

No worries, thanks for the reply.

My issue is similar to @cghiban, I have an app that uses the warehouse so I have to restart it every now and again in order to refresh the session.

farhank3389 avatar Jun 01 '23 16:06 farhank3389

oh, in your case, please set https://pkg.go.dev/database/sql#DB.SetConnMaxIdleTime

This will prevent the issue you're having. No need to restart the pod

andrefurlan-db avatar Jun 01 '23 20:06 andrefurlan-db