Fix records_yaml startup lookup race - #13538
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/records/unit_tests/test_RecRegister.cc:122
- The concurrency test currently (a) spins in a tight loop waiting for
start, and (b) allocates 100k uniquely-named metrics (strings + lookup-table entries) that can’t be cleaned up and will bloat the test process for the remainder of the suite. You can avoid the CPU spin by usingstd::atomic::wait/notify_one, and you can advance the Metrics insertion position without allocating unique names by usingts::Metrics::Counter::createSpan(1)inside the registration loop.
std::atomic<bool> start{false};
std::atomic<bool> finished{false};
std::thread register_metrics([&]() {
while (!start.load(std::memory_order_acquire)) {
std::this_thread::yield();
JosiahWI
requested changes
Aug 12, 2026
JosiahWI
left a comment
Contributor
There was a problem hiding this comment.
The fix is good. I have a request for clarification on the concurrency test.
added 2 commits
August 18, 2026 16:48
The records_yaml AuTest intermittently reported that proxy.config.diags.output.note was missing when a configuration callback ran while startup was still registering metrics. Metrics::find() returned the then-current end iterator for a miss, but RecLookupRecord() compared it with a new end iterator. An intervening registration made them differ and misread the missing string record as a numeric metric. This patch addresses the race by using the direct metrics lookup API, which reports a miss without comparing two moving end positions. It also adds a concurrent registration test that exercises string record lookups during metric creation.
The macOS CI toolchain does not provide std::jthread, and the original stress loop could finish before making a lookup. It also kept 100,000 uniquely named metrics alive for the rest of the test process. This patch uses std::thread, guarantees at least one lookup, and advances metric storage with unnamed spans so the test remains portable and focused without bloating the global metrics lookup table.
bneradt
force-pushed
the
fix-records-yaml-flake
branch
from
August 18, 2026 21:52
23b7273 to
2365516
Compare
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.
The records_yaml AuTest intermittently reported that
proxy.config.diags.output.note was missing when a configuration
callback ran while startup was still registering metrics.
Metrics::find() returned the then-current end iterator for a miss, but
RecLookupRecord() compared it with a new end iterator. An intervening
registration made them differ and misread the missing string record as
a numeric metric.
This patch addresses the race by using the direct metrics lookup API,
which reports a miss without comparing two moving end positions. It also
adds a concurrent registration test that exercises string record lookups
during metric creation.