Skip to content

Commit

Permalink
fix: always close db plugin connection
Browse files Browse the repository at this point in the history
  • Loading branch information
austingebauer committed Apr 22, 2020
1 parent 1a0918a commit 8b3f8a2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions builtin/logical/database/path_rotate_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ func (b *databaseBackend) pathRotateCredentialsUpdate() framework.OperationFunc
return nil, err
}

defer func() {
// Close the plugin
db.closed = true
if err := db.Database.Close(); err != nil {
b.Logger().Error("error closing the database plugin connection", "err", err)
}
// Even on error, still remove the connection
delete(b.connections, name)
}()

// Take out the backend lock since we are swapping out the connection
b.Lock()
defer b.Unlock()
Expand Down Expand Up @@ -135,14 +145,6 @@ func (b *databaseBackend) pathRotateCredentialsUpdate() framework.OperationFunc
b.Logger().Warn("unable to delete WAL", "error", err, "WAL ID", walID)
}

// Close the plugin
db.closed = true
if err := db.Database.Close(); err != nil {
b.Logger().Error("error closing the database plugin connection", "err", err)
}
// Even on error, still remove the connection
delete(b.connections, name)

return nil, nil
}
}
Expand Down

0 comments on commit 8b3f8a2

Please sign in to comment.