mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 23:03:10 -06:00
Only reuse connection if not a test database
This commit is contained in:
parent
47b7828a96
commit
bbf2c1376e
|
|
@ -102,7 +102,9 @@ var dbConns = make(map[string]*sql.DB)
|
||||||
// usually consisting of at least a database name and connection information. Includes tracing driver
|
// usually consisting of at least a database name and connection information. Includes tracing driver
|
||||||
// if DENDRITE_TRACE_SQL=1
|
// if DENDRITE_TRACE_SQL=1
|
||||||
func Open(dbProperties *config.DatabaseOptions) (*sql.DB, error) {
|
func Open(dbProperties *config.DatabaseOptions) (*sql.DB, error) {
|
||||||
if conn, ok := dbConns[string(dbProperties.ConnectionString)]; ok {
|
// reuse connection only if not a sqlite3 test database
|
||||||
|
isTestDB := strings.HasSuffix(string(dbProperties.ConnectionString), "_test.db")
|
||||||
|
if conn, ok := dbConns[string(dbProperties.ConnectionString)]; !isTestDB && ok {
|
||||||
logrus.Debug("Reusing existing database connection")
|
logrus.Debug("Reusing existing database connection")
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue