fix(unified-storage): don't use in-process if db type is not set (#101254)

This commit is contained in:
Jean-Philippe Quéméner
2025-02-24 21:44:42 +01:00
committed by GitHub
parent e482c037bf
commit 9282e4cad4
2 changed files with 117 additions and 8 deletions
+17 -8
View File
@@ -45,14 +45,7 @@ func NewResourceServer(db infraDB.DB, cfg *setting.Cfg,
return nil, err
}
dbCfg := cfg.SectionWithEnvOverrides("database")
// Check in the config if HA is enabled by default we always assume a HA setup.
isHA := dbCfg.Key("high_availability").MustBool(true)
// SQLite is not possible to run in HA, so we set it to false.
databaseType := dbCfg.Key("type").MustString(migrator.SQLite)
if databaseType == migrator.SQLite {
isHA = false
}
isHA := isHighAvailabilityEnabled(cfg.SectionWithEnvOverrides("database"))
store, err := NewBackend(BackendOptions{DBProvider: eDB, Tracer: tracer, IsHA: isHA})
if err != nil {
@@ -70,3 +63,19 @@ func NewResourceServer(db infraDB.DB, cfg *setting.Cfg,
return rs, nil
}
// isHighAvailabilityEnabled determines if high availability mode should
// be enabled based on database configuration. High availability is enabled
// by default except for SQLite databases.
func isHighAvailabilityEnabled(dbCfg *setting.DynamicSection) bool {
// Check in the config if HA is enabled - by default we always assume a HA setup.
isHA := dbCfg.Key("high_availability").MustBool(true)
// SQLite is not possible to run in HA, so we force it to false.
databaseType := dbCfg.Key("type").String()
if databaseType == migrator.SQLite {
isHA = false
}
return isHA
}