1
0
mirror of https://github.com/containers/podman.git synced 2026-02-05 15:45:08 +01:00

fix: prevent race condition during database initialization by using INSERT OR IGNORE.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>

test: add test to check if SQLite DB config change will mitigate race condition when multiple podman process start at once.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>

test: Check to ensure only one row was created in DBConfig table.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>

test: Changed no of processes started at once to 20.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>

test: rc reset to 0 to not affect second part of the test, db path is no longer hardcoded in test case.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>

test: Reverted test case.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>

lint: removed trailing whitespaces.

Signed-off-by: SanjayReddy91 <gamerzdamnyt1234@gmail.com>
This commit is contained in:
SanjayReddy91
2026-02-01 16:18:44 +05:30
parent 8fbda3fbef
commit 82e04e8d7f

View File

@@ -316,8 +316,10 @@ func (s *SQLiteState) ValidateDBConfig(_ *Runtime) (defErr error) {
return err
}
// Ignoring prevents a race condition where multiple Podman processes
// might try to initialize the database at the same time.
const createRow = `
INSERT INTO DBconfig VALUES (
INSERT OR IGNORE INTO DBconfig VALUES (
?, ?, ?,
?, ?, ?,
?, ?, ?