mirror of https://github.com/containers/podman.git
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:
parent
d62ef3fb21
commit
b6b61a6a49
|
@ -39,17 +39,13 @@ const (
|
||||||
sqliteOptionForeignKeys = "&_foreign_keys=1"
|
sqliteOptionForeignKeys = "&_foreign_keys=1"
|
||||||
// Make sure that transactions happen exclusively.
|
// Make sure that transactions happen exclusively.
|
||||||
sqliteOptionTXLock = "&_txlock=exclusive"
|
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.
|
// Assembled sqlite options used when opening the database.
|
||||||
sqliteOptions = "db.sql?" +
|
sqliteOptions = "db.sql?" +
|
||||||
sqliteOptionLocation +
|
sqliteOptionLocation +
|
||||||
sqliteOptionSynchronous +
|
sqliteOptionSynchronous +
|
||||||
sqliteOptionForeignKeys +
|
sqliteOptionForeignKeys +
|
||||||
sqliteOptionTXLock +
|
sqliteOptionTXLock
|
||||||
sqliteOptionBusyTimeout
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSqliteState creates a new SQLite-backed state database.
|
// 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)
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("initializing sqlite database: %w", err)
|
return nil, fmt.Errorf("initializing sqlite database: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue