File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1+ kind : BUG FIXES
2+ body : Refresh the connection upon expiration
3+ time : 2025-09-09T16:50:37.281682-05:00
4+ custom :
5+ Issue : " 134"
Original file line number Diff line number Diff line change @@ -10,15 +10,16 @@ import (
1010 "database/sql"
1111 "encoding/pem"
1212 "fmt"
13- "github.com/hashicorp/errwrap"
14- log "github.com/hashicorp/go-hclog"
15- "github.com/hashicorp/go-secure-stdlib/parseutil"
16- "github.com/hashicorp/vault/sdk/database/helper/dbutil"
1713 "net/url"
1814 "regexp"
1915 "sync"
2016 "time"
2117
18+ "github.com/hashicorp/errwrap"
19+ log "github.com/hashicorp/go-hclog"
20+ "github.com/hashicorp/go-secure-stdlib/parseutil"
21+ "github.com/hashicorp/vault/sdk/database/helper/dbutil"
22+
2223 "github.com/hashicorp/vault/sdk/database/helper/connutil"
2324 "github.com/mitchellh/mapstructure"
2425 "github.com/snowflakedb/gosnowflake"
@@ -149,8 +150,14 @@ func (c *snowflakeConnectionProducer) Connection(ctx context.Context) (interface
149150 return nil , connutil .ErrNotInitialized
150151 }
151152
153+ // If we already have a DB, test it and return
152154 if c .snowflakeDB != nil {
153- return c .snowflakeDB , nil
155+ if err := c .snowflakeDB .PingContext (ctx ); err == nil {
156+ return c .snowflakeDB , nil
157+ }
158+ // If the ping was unsuccessful, close it and ignore errors as we'll be
159+ // reestablishing anyways
160+ c .snowflakeDB .Close ()
154161 }
155162
156163 var db * sql.DB
You can’t perform that action at this time.
0 commit comments