Additional Config Store Cleanup (#16440)
This change addresses a few issues where config stores were not properly closed when an error was encountered on server startup. This could result in leaked database connections when dealing with a database config store.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9283143c3b
Коммит
fe7d9f7643
@@ -48,6 +48,12 @@ func NewDatabaseStore(dsn string) (ds *DatabaseStore, err error) {
|
||||
return nil, errors.Wrapf(err, "failed to connect to %s database", driverName)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
db.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
ds = &DatabaseStore{
|
||||
driverName: driverName,
|
||||
originalDsn: dsn,
|
||||
@@ -55,7 +61,8 @@ func NewDatabaseStore(dsn string) (ds *DatabaseStore, err error) {
|
||||
db: db,
|
||||
}
|
||||
if err = initializeConfigurationsTable(ds.db); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to initialize")
|
||||
err = errors.Wrap(err, "failed to initialize")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ds, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user