Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/development/ci.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ The workflow `test-native.yml` builds the native image of the `arcadedb` package
* The `pyver` job installs the already built `linux-x86_64` wheel (no rebuild) into the Pythons that the full parity runs of the event leave out (3.11, 3.13 and 3.14 on a push to `main`, the nightly run and a dispatch; none on a release) and into the free-threaded 3.14t, and runs 13 test files there (14 where polars installs), about 20 seconds of tests per Python. A release needs it: a `pyver` leg that passes uploads the marker `native-passed-pyver-py<version>` (it holds the file name of the wheel the leg installed), and `Verify what may be published` in `release-native.yml` requires the marker of 3.14t, the one leg of a release, and that it tested the `linux-x86_64` wheel that is published. A red leg stops a release before anything reaches PyPI. A pull request of the fast tier runs no leg of this job: every Python but 3.15 runs in the full tier. In the 30 days before issue 442 no `pyver` leg was red on a commit where the parity suite on Linux x86-64 was green. Only `linux-x86_64` is checked on 3.14t: the other platforms are not tested on it, and the JVM package has no such job. The 3.14t leg has no polars (no free-threaded wheel exists), so it skips `test_dataframe_ingest.py`. JPype 1.8.0 and later turn the GIL back on when imported, so a test file that imports `jpype` runs with the GIL there. `scripts/select_native_matrix.py` decides its legs, and `tests/test_select_native_matrix.py` and `tests/test_release_native_verify.py` pin the gate.
* Every test file runs in its own process (`native/wheel/parity_wheel.py`). A process that dies without writing its result is a `CRASH` row in `parity-wheel.tsv` with its exit code, for example `CRASH(rc=0xC0000005,3221225477)`, and it fails the leg. On the Windows legs only (the crashes of issue 295 happen there), the harness runs such a file once more in a fresh process (`--retry-crash`). A retry that produces a result is a `FLAKY-CRASH` row: the gate lets the leg pass, the job summary lists the file with the first exit code, and on a release or a dispatch the `crash-report` job adds one comment to issue 295 (run URL, Python, wheel version, exit codes). A second crash, a failing test, a timeout and every crash on Linux or macOS stay failures. A process that wrote its result and then died in shutdown is a `DIRTY-EXIT` record (exit code, file, attempt) in the metadata, the job summary and the issue comment: it is not retried and does not fail the leg. Each Windows test process also writes a faulthandler trace, `parity-wheel-xml/<file>.attemptN.fault.txt`, into the parity artifact of the leg. Only a retry hides a crash, so treat a `FLAKY-CRASH` as an open bug: read the trace in the artifact before a release is announced.
* The four tests of `tests/test_vector_read_your_writes.py` run again when they hit a known engine race, on both packages (issue 409). The engine of 26.11.1 can miss a vector that a commit has just returned: a graph rebuild trims it between the two phases of its commit. The fix is pull request 12087 of ArcadeData/arcadedb, which is in no release yet, and the test must keep detecting the race, so it is not skipped. The rerun is in the tests (`run_with_known_race_rerun` in `tests/conftest.py`), not in a workflow, so every job that runs the file has it: the parity harness and the plain runs of the JVM build. 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 #<rid> not found+`). Any other failure, and a test that fails all three runs, fails the job. Each rerun is a `UserWarning` that names issue 409 in the warnings summary of the log. A test that passed only after a rerun carries the junit property `flaky_race`: the `TOTAL` row of `parity-wheel.tsv` counts it as `flaky_race=N`, the gate step prints a `FLAKY-RACE` line, and the `crash-report` job lists the tests in the job summary. A count never fails a leg. The rerun goes when the engine release that contains the fix is out and the file has passed 100 consecutive scheduled runs; then issue 409 is closed.
* The `examples` job runs every script of `examples/` against the installed wheel of each platform (Python 3.12 and 3.14; a pull request of the fast tier: no leg) through `scripts/run_examples.sh`, the runner that `test-python-examples.yml` uses too. `scripts/native_examples_skip.txt` lists, with a reason, the examples that need the JVM package. `Examples summary` is the one check for all its legs. These legs do not decide what a release publishes.
* The `examples` job runs every script of `examples/` against the installed wheel of each platform (Python 3.12 and 3.14; a pull request of the fast tier: no leg) through `scripts/run_examples.sh`, the runner that `test-python-examples.yml` uses too. `scripts/native_examples_skip.txt` lists, with a reason, the examples that need the JVM package. `Examples summary` is the one check for all its legs. An example that reaches its timeout is treated as a hang: the runner aborts it with `SIGABRT` (not on Windows) so that the log holds the stack of every thread, prints that log, and runs the example once more. A pass on the retry is named in the results and in a warning, and a second timeout fails the leg. These legs do not decide what a release publishes.
* A native image build takes about 5 to 30 minutes for each platform (macOS is the slowest). The organisation shares one runner limit with upstream ArcadeDB, so do not add runs lightly. Change the paths or the matrix of `test-native.yml` only for a reason that you can write down.

== Change the selection
Expand Down
58 changes: 45 additions & 13 deletions scripts/run_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# EX_PY interpreter that has the package under test installed (required)
# EXAMPLES space-separated globs of the examples to run, relative to examples/ (required)
# SKIPPED_DATASETS set by the datasets step through GITHUB_ENV: datasets whose host was unreachable
# EXAMPLES_TIMEOUT optional, seconds: replaces the per-example timeouts below (the tests of this runner use it; CI does not set it)
# EXAMPLES_SKIP_FILE optional, relative to the repository root: one line per example that cannot run on this package, "<file>.py | <reason>"
# (blank lines and lines that start with # are ignored). The list is printed with its reasons and each listed example is
# counted as skipped and named. The JVM job sets no file and skips nothing.
Expand Down Expand Up @@ -149,6 +150,23 @@ run_examples() {
TIMEOUT_CMD="timeout"
fi

# A TIMEOUT IS A HANG, AND IT GETS ONE RETRY (#577). On 2026-12-04 example 13 hung for the whole 30 minutes of its timeout on one of
# 86 native runs of it since 2026-12-01 (it takes 5 to 15 minutes on every platform otherwise), with no output after the
# model load and the same example passing a minute later on the other Python of the same run. A timeout sends SIGABRT, and
# PYTHONFAULTHANDLER=1 makes Python print the stack of every thread into the log, so the next hang says where it sits (Windows has no
# SIGABRT for a native process: the default signal ends it). The log is printed, the example runs once more, and a second timeout fails.
# Only a timeout is retried: a failure is never run twice. A run that passed on its retry is named in the results and in a warning.
timeout_signal=()
case "$(uname -s)" in
MINGW* | MSYS* | CYGWIN*) ;;
*) timeout_signal=(-s ABRT) ;;
esac
# One run of the current example (its arguments are the variables of the loop below); the exit code is the answer, 124 for a timeout.
run_example_once() { # <ARCADEDB_JVM_ARGS value>
ARCADEDB_JVM_ARGS="$1" JAVA_TOOL_OPTIONS="" _JAVA_OPTIONS="" PYTHONFAULTHANDLER=1 \
$TIMEOUT_CMD "${timeout_signal[@]}" "$timeout_duration" "$EX_PY" "$example" "${example_argv[@]}" > "$log_file" 2>&1
}

# WHICH EXAMPLES NEED WHICH DATASET. Same grouping the download step
# uses to decide what to fetch, kept in the same file so the two
# cannot drift into disagreeing about what a dataset is for.
Expand Down Expand Up @@ -307,7 +325,7 @@ run_examples() {
"13_stackoverflow_hybrid_queries.py")
example_args="--dataset stackoverflow-tiny --batch-size 500 --encode-batch-size 64 --top-k 5 --candidate-limit 100 --min-reputation 100 --infer-sample-limit 5000 --run-label ci13"
example_name="$example (hybrid pipeline, tiny + minimal limits)"
timeout_duration=1800
timeout_duration=1200 # 5 to 15 minutes on every leg since 2026-12-01 (#577); it was 30 minutes
example_jvm_args=""
;;
"14_lifecycle_timing.py")
Expand Down Expand Up @@ -369,16 +387,23 @@ run_examples() {
# The argument string of the example, split on spaces into words (no globbing)
read -r -a example_argv <<< "$example_args"

# EXAMPLES_TIMEOUT replaces the timeout of the case above
timeout_duration="${EXAMPLES_TIMEOUT:-$timeout_duration}"
retried_after_timeout=0

# Run the example with appropriate parameters
if [ -n "$example_jvm_args" ]; then
if ARCADEDB_JVM_ARGS="$example_jvm_args" JAVA_TOOL_OPTIONS="" _JAVA_OPTIONS="" $TIMEOUT_CMD $timeout_duration "$EX_PY" "$example" "${example_argv[@]}" > "$log_file" 2>&1; then
exit_code=0
else
exit_code=$?
fi
if run_example_once "$example_jvm_args"; then
exit_code=0
else
if ARCADEDB_JVM_ARGS="" JAVA_TOOL_OPTIONS="" _JAVA_OPTIONS="" $TIMEOUT_CMD $timeout_duration "$EX_PY" "$example" "${example_argv[@]}" > "$log_file" 2>&1; then
exit_code=$?
fi
if [ $exit_code -eq 124 ]; then
echo "⏱️ TIMEOUT: $example_name (exceeded $timeout_duration seconds); its log, with the stack of every thread at the abort:"
tail -n 200 "$log_file"
echo "::warning title=$example hit its timeout::run once more; the log above is the first run"
if run_example_once "$example_jvm_args"; then
exit_code=0
retried_after_timeout=1
else
exit_code=$?
fi
Expand All @@ -392,7 +417,7 @@ run_examples() {
ref_args="${ref_args/--run-label ci10/--run-label ci10ref}"
read -r -a ref_argv <<< "$ref_args"
ref_log="${example%.py}-reference.log"
if ! $TIMEOUT_CMD $timeout_duration "$EX_PY" "$example" "${ref_argv[@]}" > "$ref_log" 2>&1; then
if ! $TIMEOUT_CMD "$timeout_duration" "$EX_PY" "$example" "${ref_argv[@]}" > "$ref_log" 2>&1; then
echo "❌ reference run (python_memory) of $example failed; last 20 lines:"
tail -n 20 "$ref_log"
exit_code=1
Expand All @@ -403,18 +428,25 @@ run_examples() {
fi
if [ $exit_code -eq 0 ]; then
echo "✅ PASSED: $example_name" | tee -a $results_file
if [ $retried_after_timeout -eq 1 ]; then
echo "⚠️ PASSED ON ITS RETRY after a timeout: $example_name" | tee -a $results_file
fi
passed=$((passed + 1))
else
if [ $exit_code -eq 124 ]; then
echo "⏱️ TIMEOUT: $example_name (exceeded $((timeout_duration / 60)) minutes)" | tee -a $results_file
echo "⏱️ TIMEOUT: $example_name (exceeded $timeout_duration seconds twice)" | tee -a $results_file
failed=$((failed + 1))
else
echo "❌ FAILED: $example_name (exit code: $exit_code)" | tee -a $results_file
failed=$((failed + 1))
fi
# Show last 20 lines of error log
echo "Last 20 lines of output:"
tail -n 20 "$log_file"
# Show the last lines of the error log (a timeout: the stack of every thread is in them)
tail_lines=20
if [ $exit_code -eq 124 ]; then
tail_lines=200
fi
echo "Last $tail_lines lines of output:"
tail -n "$tail_lines" "$log_file"
fi
echo ""
done
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"test_release_native_verify.py": "runs the bash code of a workflow step",
# makes a drop fail with chmod 0o500 on the database directory, which does not stop a delete on Windows (#554)
"test_drop_failure.py": "chmod cannot make a directory undeletable",
# runs scripts/run_examples.sh on fake examples, one of which a SIGABRT from timeout must end (#577)
"test_run_examples_timeout.py": "runs the examples runner under bash and SIGABRT",
}
if sys.platform == "win32":
collect_ignore.extend(WINDOWS_NOT_APPLICABLE)
Expand Down
122 changes: 122 additions & 0 deletions tests/test_run_examples_timeout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""The example runner treats a timeout as a hang: it prints the stacks, runs the example once more, and fails on a second timeout (#577).

scripts/run_examples.sh gave example 13 a timeout of 30 minutes, and on 2026-12-04 one run of it used all of them with no output after the
model load, while it takes 5 to 15 minutes on every platform otherwise. These tests run the real script on a copy of its tree with tiny
fake examples and EXAMPLES_TIMEOUT=3: a hang that goes away on the second run passes and is named, a hang that stays fails after exactly
two runs and the log holds the stack of every thread, and a plain failure is never run twice. The file is not collected on Windows
(tests/conftest.py WINDOWS_NOT_APPLICABLE): the runner is bash code for a runner, and SIGABRT is not delivered there.
"""

from __future__ import annotations

import os
import shutil
import subprocess # nosec B404 - test-controlled child processes
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]

# The fake example counts its runs in a file next to it, then hangs, fails or passes as its first line says.
FAKE = """\
import pathlib
import sys
import time

runs = pathlib.Path(__file__).with_suffix(".runs")
count = int(runs.read_text()) + 1 if runs.exists() else 1
runs.write_text(str(count))
print(f"run {count}", flush=True)
mode = pathlib.Path(__file__).with_suffix(".mode").read_text().strip()
if mode == "hang" or (mode == "hang-once" and count == 1):
time.sleep(600)
if mode == "fail":
sys.exit(3)
"""


# GNU `timeout -s SIGNAL SECONDS COMMAND...` for a machine that has neither timeout nor gtimeout (the macOS runners have no coreutils
# unless a job installs them): signal the child at the deadline, wait for it, exit 124.
TIMEOUT_SHIM = """\
#!{python}
import signal
import subprocess
import sys

args = sys.argv[1:]
sig = signal.SIGTERM
if args[0] == "-s":
sig = getattr(signal, "SIG" + args[1])
args = args[2:]
child = subprocess.Popen(args[1:])
try:
sys.exit(child.wait(timeout=float(args[0])))
except subprocess.TimeoutExpired:
child.send_signal(sig)
child.wait()
sys.exit(124)
"""


def run_runner(tmp_path: Path, mode: str):
"""Run the runner on a copy of its tree with one fake example; return (process, output file text, runs of the example)."""
(tmp_path / "scripts").mkdir()
shutil.copy(ROOT / "scripts" / "run_examples.sh", tmp_path / "scripts")
examples = tmp_path / "examples"
examples.mkdir()
(examples / "99_fake.py").write_text(FAKE)
(examples / "99_fake.mode").write_text(mode)
out = tmp_path / "github_output.txt"
env = dict(os.environ)
env.update(
EX_PY=sys.executable,
EXAMPLES="99_fake.py",
EXAMPLES_TIMEOUT="3",
GITHUB_OUTPUT=str(out),
)
env.pop("EXAMPLES_SKIP_FILE", None)
if not (shutil.which("timeout") or shutil.which("gtimeout")):
shim = tmp_path / "bin" / "timeout"
shim.parent.mkdir()
shim.write_text(TIMEOUT_SHIM.format(python=sys.executable))
shim.chmod(0o755)
env["PATH"] = str(shim.parent) + os.pathsep + env["PATH"]
done = subprocess.run( # nosec B603 B607 - fixed argument list, no shell
["bash", str(tmp_path / "scripts" / "run_examples.sh"), "run"],
env=env,
capture_output=True,
text=True,
timeout=120,
)
runs_file = examples / "99_fake.runs"
runs = int(runs_file.read_text()) if runs_file.exists() else 0
return done, out.read_text(), runs


def test_a_hang_that_goes_away_on_the_second_run_passes_and_is_named(tmp_path):
done, github_output, runs = run_runner(tmp_path, "hang-once")
assert done.returncode == 0, done.stdout + done.stderr
assert runs == 2
assert "passed=1" in github_output and "failed=0" in github_output
assert "PASSED ON ITS RETRY after a timeout" in done.stdout
assert "::warning title=99_fake.py hit its timeout" in done.stdout


def test_a_hang_that_stays_fails_after_two_runs_and_the_log_has_the_stacks(tmp_path):
done, github_output, runs = run_runner(tmp_path, "hang")
assert done.returncode == 1, done.stdout + done.stderr
assert runs == 2
assert "failed=1" in github_output
assert "TIMEOUT: 99_fake.py (exceeded 3 seconds twice)" in done.stdout
# SIGABRT with PYTHONFAULTHANDLER=1: the stack of the thread that sleeps, in the log the runner prints
assert "most recent call first" in done.stdout
assert "time.sleep" in done.stdout or "in <module>" in done.stdout


def test_a_failing_example_is_never_run_twice(tmp_path):
done, github_output, runs = run_runner(tmp_path, "fail")
assert done.returncode == 1, done.stdout + done.stderr
assert runs == 1
assert "failed=1" in github_output
assert "FAILED: 99_fake.py (exit code: 3)" in done.stdout
assert "RETRY" not in done.stdout
Loading