Skip to content

Commit

Permalink
do not close sqlite connection due to idle/max-connection time (keep …
Browse files Browse the repository at this point in the history
…alive in-memory databases)
  • Loading branch information
pk910 committed Aug 14, 2023
1 parent 809edb4 commit 013b2f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func mustInitSqlite(config *types.SqliteDatabaseConfig) (*sqlx.DB, *sqlx.DB) {
}

checkDbConn(dbConn, "database")
dbConn.SetConnMaxIdleTime(time.Second * 30)
dbConn.SetConnMaxLifetime(time.Second * 60)
dbConn.SetConnMaxIdleTime(0)
dbConn.SetConnMaxLifetime(0)
dbConn.SetMaxOpenConns(config.MaxOpenConns)
dbConn.SetMaxIdleConns(config.MaxIdleConns)

Expand Down
3 changes: 2 additions & 1 deletion test-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ indexer:
database:
engine: "sqlite"
sqlite:
file: "./tmp-database.sqlite"
#file: "./tmp-database.sqlite"
file: ":memory:"
pgsql:
host: "10.16.97.2"
port: 5432
Expand Down

0 comments on commit 013b2f6

Please sign in to comment.