Skip to content

test_a_parallel_burst_from_one_address_cannot_pass_the_limit fails at random on Windows with «database is locked» #212

Closed

Description

@lumenpearson

What is broken. server/tests/test_directory.py::test_a_parallel_burst_from_one_address_cannot_pass_the_limit fails some of the time on a Windows checkout, with no code change between a pass and a failure:

E   sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
E   [SQL: INSERT INTO join_attempts (client_key, created_at) VALUES (?, ?)]

Failure scenario. On 27 September 2026, on the branch agents/audit-docs (whose server code is 938e59f's: the branch changes two test docstrings and nothing else), Windows 11, Python 3.13.15:

  • the full suite, three xdist workers: 1 failed, 2023 passed — this test alone;
  • the test alone, pytest -q -p no:xdist -p no:cacheprovider tests/test_directory.py -k parallel_burst, three times in a row with the machine's CPU at about 2 %: failed, passed (8.2 s), failed (10.4 s).

The test fires 100 GET /api/v1/directory/school-regions at once through asyncio.gather, and every request that gets past validation writes a join_attempts row to the test's file SQLite database. The failures take longer than five seconds, which is SQLite's default busy timeout, so the likeliest reading is that the burst's writers queue on the database's one write lock and some of them wait past it. That is a reading, not a measurement. The 429 the limiter answers is what the test asserts about; an OperationalError out of a writer is a different answer, and the test reports it as a failure.

CI has not been seen failing on it: the last five ci.yml runs on main and the pull requests are green (Linux, -n auto). #186's Windows run of the full suite passed it on 26 September.

Expected. The test passes or fails on what the limiter does, not on how long SQLite waits for its lock on the machine that runs it.

Found while running the full suite for #211.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions