Skip to content

Fix records_yaml startup lookup race - #13538

Merged
bneradt merged 2 commits into
apache:masterfrom
bneradt:fix-records-yaml-flake
Aug 19, 2026
Merged

Fix records_yaml startup lookup race#13538
bneradt merged 2 commits into
apache:masterfrom
bneradt:fix-records-yaml-flake

Conversation

@bneradt

@bneradt bneradt commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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.

@bneradt bneradt added this to the 11.0.0 milestone Aug 12, 2026
Copilot AI lite review requested due to automatic review settings August 12, 2026 01:06
@bneradt bneradt self-assigned this Aug 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 12, 2026 02:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 using std::atomic::wait/notify_one, and you can advance the Metrics insertion position without allocating unique names by using ts::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 JosiahWI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix is good. I have a request for clarification on the concurrency test.

Comment thread src/records/unit_tests/test_RecRegister.cc Outdated
Comment thread src/records/unit_tests/test_RecRegister.cc Outdated
bneradt 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
bneradt force-pushed the fix-records-yaml-flake branch from 23b7273 to 2365516 Compare August 18, 2026 21:52
Copilot AI review requested due to automatic review settings August 18, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JosiahWI JosiahWI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@bneradt
bneradt merged commit 1372b5e into apache:master Aug 19, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.1 in ATS v10.2.x Aug 19, 2026
@bneradt
bneradt deleted the fix-records-yaml-flake branch August 19, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: For v10.2.1

Development

Successfully merging this pull request may close these issues.

3 participants