Skip to content

Rerun the vector read-your-writes tests on the known engine race, at most twice and counted - #463

Merged
tae898 merged 1 commit into
mainfrom
fix/409-known-race-rerun
Nov 23, 2026
Merged

tae898 merged 1 commit into
mainfrom
fix/409-known-race-rerun

Conversation

@tae898

@tae898 tae898 commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Refs #409

The vector read-your-writes tests fail intermittently on every platform and both builds because of an engine race (a graph rebuild trims a vector whose commit sits between its two phases; the fix is pull request 12087 of ArcadeData/arcadedb, not in a release yet). A red main on about every other run (issue 451 is the red-main report for it) hides every other regression and blocks the release. This pull request keeps the tests detecting the race and stops it from turning main red, by a bounded, visible, counted rerun. It is not a skip and not an xfail.

The mechanism

run_with_known_race_rerun in tests/conftest.py calls the whole test body again, on a fresh database, at most 2 more times (3 runs), and only when the failure is one of the three signatures below. Any other failure is raised at once, and a body that fails all 3 runs fails (the exception of the last run, with a note naming #409). The number of reruns is a constant: no environment variable, option or marker raises it. In tests/test_vector_read_your_writes.py a decorator known_race_test gives each of the 4 tests its own corpus per run (tmp_path / read_your_writes_<n>, dropped after the run) and passes the body the same (db, index) the corpus fixture used to give it. The assertions of the tests are unchanged.

Why it is inside the tests and not in a harness: the file runs in two kinds of job. The parity harness runs it on the native wheel, one process per file. The JVM jobs run plain python -m pytest tests/ on Linux, macOS and Windows. A --retry-crash style option of the harness would leave the second kind red, and a plugin such as pytest-rerunfailures would be a new dependency for the one file. One mechanism in the test code covers both and applies to that one file only (a test checks that no other test file uses it).

The three signatures

The class is matched by name along its bases and the message by a pattern, so a text on the wrong class does not match.

Signature Class Where I read it
N of M committed vectors were not found ... AssertionError the assertion of the 4 tests, in the comments of #409
Vector search failed ArcadeDBError find_nearest wraps what the engine raised (src/arcadedb/vector.py)
Record #<n>:<n> not found ArcadeDBError the cause that Vector search failed carries in the two logs below

All three are the one race: a vector whose commit has returned is missing from the next search (the assertion), or the search returns an RID whose record is not readable yet (the load of the hit raises RecordNotFoundException, which find_nearest wraps as Vector search failed: ...). I read the logs of run 45044368506 (macOS, JVM wheel) and run 45088615472 (Windows, JVM wheel, Python 3.14): both end in ArcadeDBError: Vector search failed: com.arcadedb.exception.RecordNotFoundException: Record #1:489 not found and ... Record #1:360 not found. I did not find a log of the native build with the RecordNotFoundException text, so the third pattern allows the message with or without the Vector search failed prefix. The match is on text and class, not on the frame the exception came from.

How a rerun shows

  • A UserWarning per rerun that names ArcadeData/arcadedb-python#409, the run (run 1 of 3, rerun 1 of 2) and the first line of the failure. It is in the warnings summary of the test log on every job.
  • A test that passed only after a rerun adds the junit property flaky_race (its value is the number of reruns). I append it to request.node.user_properties and do not use the record_property fixture: that fixture emits a PytestWarning on every use under the default junit_family of the JVM jobs, so it would warn on runs without any rerun.
  • The native parity harness (native/wheel/parity_wheel.py) counts the tests with that property: flaky_race=N at the end of the status column of the TOTAL row (the 11 columns are unchanged), a ::warning:: line per test in the run log, and race_events in parity-wheel.meta.json. report_flaky_crash.py adds a block "Known engine race reruns" to the job summary of the crash-report job and posts nothing anywhere. The two gate programs of test-native.yml print a FLAKY-RACE line and never fail on it (the edit is one capture and one print line in each program, the same in both). The JVM jobs have no counter beyond the warning and the junit property: I did not touch test-jvm.yml.

When it goes

The REMOVE WHEN comment at the mechanism: the engine release that contains the upstream fix is merged and released, and tests/test_vector_read_your_writes.py has passed 100 consecutive scheduled runs. Then the block, its use, tests/test_known_engine_race_rerun.py, the counter and the paragraph in ci.adoc are deleted and #409 is closed.

Not changed

The assertions of the tests, the engine, src/, the Java of native/, the release files and test-jvm.yml. CONTRIBUTING.md is not touched; the policy is written once, in docs/modules/ROOT/pages/development/ci.adoc.

Tests

tests/test_known_engine_race_rerun.py has plain functions on fake bodies (no engine, no database): a pass is called once; a failure with a signature and then a pass is a pass with one warning and the count; two failures and a pass give two warnings; three failures fail; other messages and the right message on the wrong class are called once; only the three signatures match; no environment variable raises the number of reruns; only the one file uses the mechanism and all 4 of its tests do; each run gets a new database and every database is dropped (a fake database); the harness counts the property and not a failed test; a real junit record from a child process carries the property in both families; the TOTAL line and the job summary. The tests of the gate programs with flaky_race=0 and flaky_race=2 are in tests/test_parity_gate_awk.py, the file that already runs those programs and is not collected on Windows. The three exact TOTAL status strings of tests/test_parity_crash_retry.py now end in flaky_race=0.

Checks I ran

The repository's test runner was not run for this change; CI runs it. The full tier has not run on this change: the pull request runs the fast tier only.

Check Result
compile(source, name, "exec") on the 7 changed Python files all 7 compile
uv run --with pyflakes python -m pyflakes on the same files no output, exit 0
uvx pre-commit run --files on the 8 changed files other than the docs page (black 26.10.1, isort, ruff 0.17.4, actionlint, whitespace and YAML hooks) every hook that had a file passed, the rest had no file
uvx bandit==1.9.4 -c pyproject.toml -r src tests --severity-level low --confidence-level low exit 0
a script that imports the modules with stubbed engine modules and calls each new test function by hand, and the gate tests against both gate programs with the local awk 33 calls, 33 ok, 0 failed (the one test that starts a child runner is left to CI)

…most twice and counted (refs #409)

The four tests of tests/test_vector_read_your_writes.py fail intermittently on every platform and both builds because of the engine race that pull request 12087 of ArcadeData/arcadedb fixes (a graph rebuild trims a vector whose commit sits between its two phases). A red main on about every other run hides every other regression. I keep the tests detecting the race and stop it from turning main red: a test body runs again on a fresh database, at most twice, and only when it failed with one of the three messages of the race (`committed vectors were not found`, `Vector search failed`, `Record #... not found`). Any other failure is never retried and a body that fails all three runs fails.

The mechanism is run_with_known_race_rerun in tests/conftest.py, used by a decorator in the test file, so it covers every job that runs the file: the parity harness on the native wheel and the plain runs of the JVM build. Each rerun is a UserWarning that names issue 409, and a pass after a rerun adds the junit property flaky_race (set on the node directly: the record_property fixture warns on every use with the junit family of the JVM jobs). The parity harness counts it as flaky_race=N in its TOTAL row, prints a warning line for each test and lists it in the metadata; report_flaky_crash.py adds a block to the job summary; the two gate programs of test-native.yml print a FLAKY-RACE line and never fail on it.

The comment at the mechanism says when it goes: the engine release that contains that pull request and 100 consecutive scheduled runs of the file. The assertions of the tests and the engine are unchanged.
@tae898 tae898 added this to the 26.12.1 milestone Nov 23, 2026
@tae898 tae898 added bug Something isn't working python Pull requests that update python code vector Vector indexes and find_nearest labels Nov 23, 2026
@tae898 tae898 self-assigned this Nov 23, 2026
@tae898
tae898 merged commit 0d5ed27 into main Nov 23, 2026
25 checks passed
@tae898
tae898 deleted the fix/409-known-race-rerun branch November 23, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python Pull requests that update python code vector Vector indexes and find_nearest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant