mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-20 06:07:05 +00:00
fix: Resolve inconsistent usage of error variables (#10060)
* fix: Resolve inconsistent usage of error variables * mysql2: guard nil DB on open failure and wrap connect error --------- Co-authored-by: muminglei <muminglei@cmict.chinamobile.com> Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
co-authored by
muminglei
Chris Lu
parent
6de283ccaa
commit
16c3f5c816
@@ -80,9 +80,11 @@ func (store *MysqlStore2) initialize(createTable, upsertQuery string, enableUpse
|
||||
var dbErr error
|
||||
store.DB, dbErr = sql.Open("mysql", sqlUrl)
|
||||
if dbErr != nil {
|
||||
store.DB.Close()
|
||||
if store.DB != nil {
|
||||
store.DB.Close()
|
||||
}
|
||||
store.DB = nil
|
||||
return fmt.Errorf("can not connect to %s error:%v", adaptedSqlUrl, err)
|
||||
return fmt.Errorf("can not connect to %s error:%w", adaptedSqlUrl, dbErr)
|
||||
}
|
||||
|
||||
store.DB.SetMaxIdleConns(maxIdle)
|
||||
|
||||
Reference in New Issue
Block a user