Skip to content

Commit 57a5136

Browse files
committed
test(location): take the held-lock case's warehouse lock between syncs
The DuckDB overlap case took its write lock while the restored sync was still reading, so the busy report landed on whichever table that sync had reached. With pages read back to back that is no longer source_freshness. The case now waits for the sync to finish and expects the next sync's first table to report the lock.
1 parent cf1a356 commit 57a5136

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎benchmarks/duckshop/edge_cases/orchestration/incremental_warehouse_history.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"held_write_lock": {
1919
"duckdb": [
2020
{
21-
"held": {"failure": "busy", "tables": ["source_freshness"]},
21+
"held": {"failure": "busy", "tables": ["fingerprints"]},
2222
"released": {"failure": null, "tables": ["fingerprints", "source_freshness"]}
2323
}
2424
],

‎tests/integration/src/sqlbuild/compiler/compiled_project/publication/helpers.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,18 @@ def wait_for_log(
525525
time.sleep(0.02)
526526

527527

528+
def wait_for_idle_sync(process: subprocess.Popen[bytes], log: Path) -> None:
529+
"""Wait until the latest synchronization has completed, so a held lock meets the next one."""
530+
531+
deadline: float = time.monotonic() + 45
532+
text: str = log.read_text()
533+
while text.rfind("synchronization completed.") < text.rfind("Reading warehouse history"):
534+
assert process.poll() is None, text
535+
assert time.monotonic() < deadline, text
536+
time.sleep(0.05)
537+
text = log.read_text()
538+
539+
528540
def location_health_reports(api: SnapshotApi) -> list[dict[str, Any]]:
529541
request: Request = Request(
530542
f"{api.url}/api/locations/{api.location_id}/health",

‎tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_warehouse_metadata.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
snapshot_api,
7070
sync_warehouse_history,
7171
wait_for_generation,
72+
wait_for_idle_sync,
7273
wait_for_location_work,
7374
wait_for_warehouse_sync_health,
7475
warehouse_history_page,
@@ -1164,6 +1165,7 @@ def test_given_durable_mirror_when_late_rows_arrive_then_incremental_overlap_pre
11641165
assert (project / "warehouse.db").exists() == availability["available"]
11651166
held_locks: list[dict[str, Any]] = fixture["held_write_lock"][test_case.adapter_name]
11661167
for held_lock in held_locks:
1168+
wait_for_idle_sync(location, log)
11671169
lock: duckdb.DuckDBPyConnection = hold_write_lock(project / "warehouse.db")
11681170
record_finished_run(control)
11691171
reports = wait_for_warehouse_sync_health(

0 commit comments

Comments
 (0)