Repository navigation
test(backend): stabilize SEC-04 log captures against tracing callsite-interest races - #185
Merged
Merged
Conversation
…oisoning tracing-core caches Interest per callsite process-wide. While at most one dispatcher has ever been registered, a first hit is resolved from the registering thread's default subscriber, so a parallel no-subscriber test thread could cache Interest::never for upstream_photo_failure and silently drop the captured warn events (SEC-04 flake). Register one permanent no-op dispatcher so the registry stays on the multi-dispatcher path. Add an isolated deterministic regression that fails without it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test-only fix for the intermittent SEC-04 capture flake (
a_contentless_provider_payload_is_not_written_to_logsfailing with an empty captured log). Product logging behavior is unchanged; no assertions, markers, retries, timeouts, DB gating or suite parallelism were touched.Root cause
tracing-core caches each callsite's
Interestprocess-wide on first execution. While at most one dispatcher has ever been registered, a first hit is resolved from the registering thread's default subscriber (Dispatchers::rebuilder()->Rebuilder::JustOne). Under a parallel cargo-test run, a gateway test thread without a scoped subscriber could therefore cacheInterest::neverfor the sharedupstream_photo_failurecallsite, silently dropping the WARN event before it reached the capturingfmtsubscriber on the test thread (verified interleaving: tracing 0.1.44 / tracing-core 0.1.36 / tracing-subscriber 0.3.23, independent second look inwork/security-logtest/second-look.md).Change
apps/backend/src/legacy_api/tests/mod.rsonly:NoSubscriber) dispatch incapture_logsbefore the scoped capturing subscriber, so the global registry is never on theJustOnefast path while captures are active (Interest::and(never, always) == sometimes, decided per thread byenabled()).std::threadfirst-executes a warn callsite reserved for the test, then the capturing thread re-emits the same callsite and asserts it was captured. It fails on the previous tree (reproduced in isolation) and passes with the guard.Evidence
invalid_jsontest still passed; mutations reverted, tests greencargo fmt --all --check,cargo check -p macro-tracker-backend --lockedgitleaks git origin/staging..HEAD)Two remaining failures over the 50 runs were the pre-existing barcode stub transport flake (
all_genuine_misses_still_return_not_found,a_successful_fallback_wins_over_an_outage: 503 vs 200, no log capture involved) — explicitly out of scope and not bundled here.App version stays 3.6.0: test-only change, no feature behavior.