Skip to content

test(http): atomically claim metrics phase expiry - #1225

Merged
Coldwings merged 1 commit into
mainfrom
test/metrics-phase-expiry-1224
Sep 9, 2026
Merged

Coldwings merged 1 commit into
mainfrom
test/metrics-phase-expiry-1224

Conversation

@Coldwings

@Coldwings Coldwings commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Description

Prevent the HTTP metrics supervisor from cancelling a completed or replacement
phase based on a stale deadline snapshot. Reading an atomic deadline and later
checking the clock was not an atomic expiry decision: the worker could clear
or replace that deadline between those operations.

Type of Change

  • Tests
  • Build/CI (register the deterministic unit regression)

Related Issues

Closes #1224
Related to #1219

This is authorized test maintenance of a personal open-source project. This
reachable fixture race is independently confirmed; it does not establish the
cause of #1219's historical TLS timeout, which remains under investigation.

Changes Made

Core Changes

  • Claim phase expiry with compare-and-exchange only while the sampled deadline
    is still current. A cleared or replaced snapshot cannot cancel later work.
  • Keep the selected timeout outcome once the supervisor wins the claim.
  • Keep whole-trial expiry independent and record the cause from the same
    decision used to select cancellation.
  • Add five deterministic, sleep-free tests for both transition orderings,
    deadline replacement, inclusive expiry and disabled/unexpired deadlines.

API Changes and Compatibility

None. This changes test infrastructure only. The 10-second phase deadline,
5-second response-write budget and 60-second whole-trial deadline are unchanged.
No library API, migration, README, wiki or changelog change is applicable.

Testing

  • Focused unit regression: 5 cases / 17 assertions pass normally and under
    ASAN+UBSAN and TSAN (GCC 12.2, warnings as errors).
  • Mutation sensitivity: restoring the old stale-snapshot decision fails
    3 of the 5 cases; this is a controlled regression, not a recurrence of [Tests] Investigate intermittent HTTP TLS metrics timeout with partial-response evidence #1219.
  • Real fixture Release build, TLS enabled, limited to two build jobs.
  • Existing report-validation and real failure suites pass (39 report
    tests and 3 failure scenarios, including genuine phase inactivity timeout).
  • Verified six-coordinate TCP/TLS metrics run on the final commit: 6/6
    attributable coordinates pass, with peer length/hash verification.
  • Current-head CI and review gates complete: x64/arm64 Debug and Release,
    HTTP contracts/metrics, package consumer and CodeQL all pass. README-only
    validation is intentionally skipped. Copilot and two independent reviews
    have no blocking concerns; no unresolved review threads remain.

Full Debug CI: normal and ASAN each pass 1,304 cases on x64 / 1,303 on arm64.
TSAN passes 1,300 cases on x64 / 1,299 on arm64, with four existing explicit
skips per architecture. Full logs contain no sanitizer diagnostic.

Reproducible integration commands (using an out-of-source BUILD_DIR with
TLS, HTTP and ELIO_BUILD_HTTP_METRICS enabled):

cmake --build "$BUILD_DIR" --target elio_http_streaming_metrics_server --parallel 2
ctest --test-dir "$BUILD_DIR" -R '^http_streaming_metrics_(report|failure)_tests$' --output-on-failure
python tests/integration/http_streaming_metrics.py \
  --server "$BUILD_DIR/tests/elio_http_streaming_metrics_server" \
  --output-dir "$RESULT_DIR"

Unit filter: [http][metrics][supervision], random seed 1224.
Transport results are diagnostic; they do not establish benchmark rankings.

Checklist

  • Scoped changes; no generated artifacts or debug instrumentation committed
  • Non-obvious atomic decision documented in the helper
  • Deterministic regression proves the old decision incorrect
  • No widened timeout and no weakened failure expectation
  • Independent correctness/concurrency and test/contract reviews
  • Final-head checks and reviews clear

Reviewer Guidance

Check the linearization point between worker phase transitions and supervisor
expiry, the independent whole-trial deadline, and that the production fixture
uses the same helper exercised by the unit regressions. The helper tests force
the relevant operation ordering without relying on scheduler timing; the real
failure suite separately checks that genuine inactivity still fails.

Copilot AI balanced review requested due to automatic review settings September 9, 2026 21:13
@Coldwings

Copy link
Copy Markdown
Owner Author

Two independent read-only reviews of the current PR head found no blocking concerns. The concurrency review checked the compare-and-exchange expiry decision, deadline replacement, equal-valued deadlines and the independent whole-trial timeout. The test/contract review checked deterministic ordering coverage, use of the same helper in the real supervisor, CMake registration and unchanged timeout budgets. Both confirmed that rebasing onto the merged WebSocket fixture change introduced no interaction. Focused normal/ASAN+UBSAN/TSAN regressions, all six verified TCP/TLS coordinates and the existing report/failure suites pass on this head. The historical cause of #1219 remains unproven; this PR closes only #1224.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The atomic linearization point, timeout attribution, and deterministic coverage match the stated fixture contract.

Pull request overview

Prevents stale HTTP metrics phase deadlines from cancelling completed or replacement phases.

Changes:

  • Adds atomic compare-and-exchange expiry claiming.
  • Uses the helper in the metrics supervisor.
  • Adds five deterministic regression tests and registers them.
File summaries
File Description
tests/integration/http_metrics_supervision.hpp Defines atomic expiry claiming.
tests/integration/http_streaming_metrics_server.cpp Applies atomic phase-timeout selection.
tests/unit/test_http_metrics_supervision.cpp Covers deadline transition orderings and boundaries.
tests/CMakeLists.txt Registers the new unit tests.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Coldwings
Coldwings merged commit 430e422 into main Sep 9, 2026
14 checks passed
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.

[Tests] Claim metrics phase expiry atomically before cancelling the trial

2 participants