Skip to content

Commit 5697916

Browse files
authored
Revert "fix: database is locked (#2393)" (#2415)
This reverts commit 3ba46b6.
1 parent d9b2394 commit 5697916

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

db/mysql/mysql.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,11 @@ func CreateManager(config config.Config) (*Manager, error) {
121121
}
122122
}
123123
}
124-
db, err = gorm.Open("sqlite3", "/db/region.sqlite3?cache=shared&_busy_timeout=30000")
124+
db, err = gorm.Open("sqlite3", "/db/region.sqlite3")
125125
if err != nil {
126126
return nil, err
127127
}
128-
// 获取底层的 sql.DB 对象并设置连接池参数
129-
sqlDB := db.DB()
130-
// SQLite 应该使用单个写连接来避免锁定问题
131-
sqlDB.SetMaxOpenConns(1)
132-
sqlDB.SetMaxIdleConns(1)
133-
sqlDB.SetConnMaxLifetime(0)
134-
135-
// 设置 WAL 模式以提高并发性能
136128
db.Exec("PRAGMA journal_mode = WAL")
137-
// 设置同步模式为 NORMAL 以提高性能
138-
db.Exec("PRAGMA synchronous = NORMAL")
139-
// 设置 busy_timeout
140-
db.Exec("PRAGMA busy_timeout = 30000")
141129
}
142130
if config.ShowSQL {
143131
db = db.Debug()

0 commit comments

Comments
 (0)