mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-04 12:01:23 +02:00
Ping the mongo session when the connection is retrieved.
This was in the deprecated backend where it fixed a similar issue a long time ago but for some reason didn't make it over. Additionally the function wasn't being locked properly. Hopefully fixes #2973
This commit is contained in:
parent
6a74c119f3
commit
3ba108f51e
@ -90,12 +90,18 @@ func (c *mongoDBConnectionProducer) Initialize(ctx context.Context, conf map[str
|
||||
|
||||
// Connection creates a database connection.
|
||||
func (c *mongoDBConnectionProducer) Connection(_ context.Context) (interface{}, error) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
if !c.Initialized {
|
||||
return nil, connutil.ErrNotInitialized
|
||||
}
|
||||
|
||||
if c.session != nil {
|
||||
return c.session, nil
|
||||
if err := c.session.Ping(); err == nil {
|
||||
return c.session, nil
|
||||
}
|
||||
c.session.Close()
|
||||
}
|
||||
|
||||
dialInfo, err := parseMongoURL(c.ConnectionURL)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user