mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00
libpod: add hidden env to set sqlite timeout
Some users want to experiment with different timeout values. Fixes #23236 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -39,17 +39,13 @@ const (
|
||||
sqliteOptionForeignKeys = "&_foreign_keys=1"
|
||||
// Make sure that transactions happen exclusively.
|
||||
sqliteOptionTXLock = "&_txlock=exclusive"
|
||||
// Make sure busy timeout is set to high value to keep retrying when the db is locked.
|
||||
// Timeout is in ms, so set it to 100s to have enough time to retry the operations.
|
||||
sqliteOptionBusyTimeout = "&_busy_timeout=100000"
|
||||
|
||||
// Assembled sqlite options used when opening the database.
|
||||
sqliteOptions = "db.sql?" +
|
||||
sqliteOptionLocation +
|
||||
sqliteOptionSynchronous +
|
||||
sqliteOptionForeignKeys +
|
||||
sqliteOptionTXLock +
|
||||
sqliteOptionBusyTimeout
|
||||
sqliteOptionTXLock
|
||||
)
|
||||
|
||||
// NewSqliteState creates a new SQLite-backed state database.
|
||||
@ -71,7 +67,18 @@ func NewSqliteState(runtime *Runtime) (_ State, defErr error) {
|
||||
return nil, fmt.Errorf("creating root directory: %w", err)
|
||||
}
|
||||
|
||||
conn, err := sql.Open("sqlite3", filepath.Join(basePath, sqliteOptions))
|
||||
// Make sure busy timeout is set to high value to keep retrying when the db is locked.
|
||||
// Timeout is in ms, so set it to 100s to have enough time to retry the operations.
|
||||
// Some users might want to experiment with different timeout values (#23236)
|
||||
// DO NOT DOCUMENT or recommend PODMAN_SQLITE_BUSY_TIMEOUT outside of testing.
|
||||
busyTimeout := "100000"
|
||||
if env, ok := os.LookupEnv("PODMAN_SQLITE_BUSY_TIMEOUT"); ok {
|
||||
logrus.Debugf("PODMAN_SQLITE_BUSY_TIMEOUT is set to %s", env)
|
||||
busyTimeout = env
|
||||
}
|
||||
sqliteOptionBusyTimeout := "&_busy_timeout=" + busyTimeout
|
||||
|
||||
conn, err := sql.Open("sqlite3", filepath.Join(basePath, sqliteOptions+sqliteOptionBusyTimeout))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("initializing sqlite database: %w", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user