Skip to content

Commit

Permalink
[Snowflake] Fix idle auth error (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Sep 17, 2024
1 parent 46f4b51 commit fda4bf1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clients/snowflake/writes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func (s *Store) Append(tableData *optimization.TableData, _ bool) error {
var err error
for i := 0; i < maxRetries; i++ {
if i > 0 {
// TODO: remove
if IsAuthExpiredError(err) {
slog.Warn("Authentication has expired, will reload the Snowflake store and retry appending", slog.Any("err", err))
if connErr := s.reestablishConnection(); connErr != nil {
Expand Down Expand Up @@ -49,6 +50,7 @@ func (s *Store) Merge(tableData *optimization.TableData) error {
var err error
for i := 0; i < maxRetries; i++ {
if i > 0 {
// TODO: Remove
if IsAuthExpiredError(err) {
slog.Warn("Authentication has expired, will reload the Snowflake store and retry merging", slog.Any("err", err))
if connErr := s.reestablishConnection(); connErr != nil {
Expand Down
4 changes: 4 additions & 0 deletions lib/config/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ func (s Snowflake) ToConfig() (*gosnowflake.Config, error) {
Region: s.Region,
Application: s.Application,
Params: map[string]*string{
// This parameter will cancel in-progress queries if connectivity is lost.
// https://docs.snowflake.com/en/sql-reference/parameters#abort-detached-query
"ABORT_DETACHED_QUERY": ptr.ToString("true"),
// This parameter must be set to prevent the auth token from expiring after 4 hours.
// https://docs.snowflake.com/en/user-guide/session-policies#considerations
"CLIENT_SESSION_KEEP_ALIVE": ptr.ToString("true"),
},
}

Expand Down

0 comments on commit fda4bf1

Please sign in to comment.