Skip to content

TEST: Make score observation contention checks deterministic - #3255

Merged
Richard Lundeen (richlundeen) merged 2 commits into
microsoft:mainfrom
richlundeen:richlundeen-score-observation-test-reliability
Oct 16, 2026
Merged

Richard Lundeen (richlundeen) merged 2 commits into
microsoft:mainfrom
richlundeen:richlundeen-score-observation-test-reliability

Conversation

@richlundeen

Copy link
Copy Markdown
Contributor

Description

Make the score-observation insert/delete contention test independent of the time needed to commit the holder transaction.

The Windows Python 3.13 dev job for #3195 failed in [True-False] with sqlite3.OperationalError: database is locked at the competing BEGIN IMMEDIATE. The test call took 25.23 seconds. The event used by the test fires before SQLite attempts to acquire the lock. It does not guarantee that the holder can commit before SQLite's busy timeout expires. The log does not establish the exact cause of that delay.

A local probe reproduced the same error by holding the first transaction open until the competing write returned SQLITE_BUSY. The probe used a 1 ms busy timeout to avoid a slow reproduction.

The revised test:

  • Keeps the holder transaction open while a second session makes a real write attempt.
  • Sets busy_timeout=0 on competing connections and requires the exact SQLITE_BUSY error at BEGIN IMMEDIATE. Other database errors still fail the test.
  • Commits the holder, then makes the competing operation in a fresh session. The deletion-first case must reject the missing observation; the insertion-first case must retain the replay score's observation link.
  • Retains the observation and score-count assertions and adds an exact score-link assertion.

This is a test-only change. It does not add production retries, change production timeouts, or change memory responsibilities. It is independent of the analytics changes in #3195.

Tests and Documentation

Local validation used Windows and uv-managed Python 3.14.2:

  • uv sync --frozen --extra all: passed; uv.lock is unchanged.
  • uv run --no-sync pytest tests\unit\memory\memory_interface\test_interface_observations.py -q --tb=short: passed, 48 tests.
  • uv run --no-sync pytest tests\unit\memory\memory_interface\test_interface_observations.py -k concurrent_insert_and_final_delete -q --tb=short: passed in 10 separate runs, 40 cases total.
  • uv run --no-sync pre-commit run --all-files: passed, all hooks. The first run formatted the new assertion; the second run passed without changes.

No public behavior or documentation changed. JupyText execution and the full unit suite were not run.

Assert SQLITE_BUSY while the holder transaction is open, then verify both post-commit outcomes without a scheduler-dependent busy wait.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fe8ae25e-f344-41f5-88b3-679c29f3a498
Comment thread tests/unit/memory/memory_interface/test_interface_observations.py
Assert that a competing SQLITE_BUSY attempt cannot reach observation validation before acquiring its write lock.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fe8ae25e-f344-41f5-88b3-679c29f3a498
@richlundeen
Richard Lundeen (richlundeen) added this pull request to the merge queue Oct 16, 2026
Merged via the queue into microsoft:main with commit f1ad41c Oct 16, 2026
93 of 95 checks passed
@richlundeen
Richard Lundeen (richlundeen) deleted the richlundeen-score-observation-test-reliability branch October 16, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants