fix: flaky test (#11428)

stage1_concurrent_claims_respect_running_cap was flaky due to SQLite
lock contention, not cap logic correctness. The claim flow used deferred
transactions (BEGIN) with read-then-write behavior, which can fail under
concurrency with SQLITE_BUSY_SNAPSHOT/database is locked when upgrading
a read transaction to a write transaction. We fixed this by using BEGIN
IMMEDIATE for stage1 and phase2 claim paths, so lock acquisition happens
up front and contenders serialize cleanly instead of failing during
upgrade. After the change, codex-state tests pass and stress reruns of
the flaky path no longer reproduced the failure.
This commit is contained in:
jif-oai
2026-02-11 10:23:18 +00:00
committed by GitHub
Unverified
parent 476c1a7160
commit 2c5eeb6b1f
2 changed files with 2 additions and 3 deletions
-1
View File
@@ -1272,7 +1272,6 @@ WHERE id = 1
}
#[tokio::test]
#[ignore = "TODO(jif): flaky"]
async fn stage1_concurrent_claims_respect_running_cap() {
let codex_home = unique_temp_dir();
let runtime = StateRuntime::init(codex_home.clone(), "test-provider".to_string(), None)
+2 -2
View File
@@ -174,7 +174,7 @@ LIMIT ?
let thread_id = thread_id.to_string();
let worker_id = worker_id.to_string();
let mut tx = self.pool.begin().await?;
let mut tx = self.pool.begin_with("BEGIN IMMEDIATE").await?;
let existing_output = sqlx::query(
r#"
@@ -424,7 +424,7 @@ WHERE kind = ? AND job_key = ?
let ownership_token = Uuid::new_v4().to_string();
let worker_id = worker_id.to_string();
let mut tx = self.pool.begin().await?;
let mut tx = self.pool.begin_with("BEGIN IMMEDIATE").await?;
let existing_job = sqlx::query(
r#"