From 82e04e8d7feadfc78591863f78c3f8c1ac6cceec Mon Sep 17 00:00:00 2001 From: SanjayReddy91 Date: Sun, 1 Feb 2026 16:18:44 +0530 Subject: [PATCH] fix: prevent race condition during database initialization by using INSERT OR IGNORE. Signed-off-by: SanjayReddy91 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 test: Check to ensure only one row was created in DBConfig table. Signed-off-by: SanjayReddy91 test: Changed no of processes started at once to 20. Signed-off-by: SanjayReddy91 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 test: Reverted test case. Signed-off-by: SanjayReddy91 lint: removed trailing whitespaces. Signed-off-by: SanjayReddy91 --- libpod/sqlite_state.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libpod/sqlite_state.go b/libpod/sqlite_state.go index 39296562fd..7c9c773a7f 100644 --- a/libpod/sqlite_state.go +++ b/libpod/sqlite_state.go @@ -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 ( ?, ?, ?, ?, ?, ?, ?, ?, ?