make configurable wal auto checkpoint (#2242)

This commit is contained in:
Kristoffer Dalby 2024-11-23 21:03:48 +01:00 committed by GitHub
parent dc17b4d378
commit 64bb56352f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View file

@ -543,10 +543,10 @@ func openDB(cfg types.DatabaseConfig) (*gorm.DB, error) {
}
if cfg.Sqlite.WriteAheadLog {
if err := db.Exec(`
if err := db.Exec(fmt.Sprintf(`
PRAGMA journal_mode=WAL;
PRAGMA wal_autocheckpoint=0;
`).Error; err != nil {
PRAGMA wal_autocheckpoint=%d;
`, cfg.Sqlite.WALAutoCheckPoint)).Error; err != nil {
return nil, fmt.Errorf("setting WAL mode: %w", err)
}
}