From 96ff85791082344943eb2c36852f0f2343d344a7 Mon Sep 17 00:00:00 2001 From: Will Pfleger Date: Mon, 2 Nov 2026 16:09:33 -0500 Subject: [PATCH] test(relay): bind incremental cancellation wait to the lock holder Wait for a backend blocked by the held transaction's PID instead of any cluster-wide artifact lock waiter, matching the sync policy test. Co-authored-by: Will Pfleger Signed-off-by: Will Pfleger --- .../sync_access_postgres_tests.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/buzz-relay/src/api/artifact_postgres_tests/sync_access_postgres_tests.rs b/crates/buzz-relay/src/api/artifact_postgres_tests/sync_access_postgres_tests.rs index d10b85e859..be94cbb238 100644 --- a/crates/buzz-relay/src/api/artifact_postgres_tests/sync_access_postgres_tests.rs +++ b/crates/buzz-relay/src/api/artifact_postgres_tests/sync_access_postgres_tests.rs @@ -618,6 +618,10 @@ async fn dropped_incremental_read_keeps_its_filter_summary() { .execute(&mut *lock) .await .unwrap(); + let blocker_pid: i32 = sqlx::query_scalar("SELECT pg_backend_pid()") + .fetch_one(&mut *lock) + .await + .unwrap(); let (capture, out) = crate::access::tests::capture_access_only(tracing::Level::WARN); let mut request = Box::pin(f.request("/query", body)); // Poll the request until its candidate read waits on the lock. @@ -626,13 +630,14 @@ async fn dropped_incremental_read_keeps_its_filter_summary() { _ = &mut request => panic!("the read must wait on the locked table"), () = tokio::time::sleep(std::time::Duration::from_millis(20)) => {} } - let waiting: i64 = sqlx::query_scalar( - "SELECT count(*) FROM pg_stat_activity WHERE wait_event_type='Lock' AND query LIKE '%artifact_heads%'", + let blocked: bool = sqlx::query_scalar( + "SELECT EXISTS(SELECT 1 FROM pg_stat_activity WHERE $1=ANY(pg_blocking_pids(pid)))", ) + .bind(blocker_pid) .fetch_one(&f.pool) .await .unwrap(); - if waiting > 0 { + if blocked { break; } }