Skip to content

Relax ordering constraints in oximeter counter tests - #7262

Merged
bnaecker merged 1 commit into
mainfrom
fix-oximeter-self-stat-race
Dec 19, 2024
Merged

bnaecker merged 1 commit into
mainfrom
fix-oximeter-self-stat-race

Conversation

@bnaecker

Copy link
Copy Markdown
Collaborator

- Allow server and collection-task-side counters to differ by at most
  one in tests checking that we track requests in the task.
- Fixes #7255
@bnaecker
bnaecker requested a review from jgallagher December 17, 2024 18:31
// than our own. But since the collection task is single-threaded, it
// cannot ever be more than _one_ greater than our count, since we
// should increment that counter before making another request to the
// server.

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.

With apologies for my lack of context: I don't follow the argument about the collection task being single-threaded. Is the "off by one" because there's a window between when we get stats from the collector and when we read the server_count atomic where the collector could send additional requests? How does the collection task being single threaded mean that window allows at most 1?

Is it possible to cleanly shut down the collector? Would it make sense to shut down the collector, get the final stats from it, then compare that to server_count? (I'm wondering if we can deterministically close the window where the collector could do more stuff.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think the sequence where we're off by one goes like this:

  • The inner spawned task makes a request to the server
  • The server bumps its counter and then responds
  • We ask for the collection task's counts, which is one fewer than the server side
  • The inner collection task sends its result to the outer collection task, which bumps its counter. They're now equal.

Is it possible to cleanly shut down the collector?

This is what I was hoping to do, but it's not possible with the API today to shutdown the collector and then get its stats out. We could make the shutdown method return the current stats, possibly?

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.

Is it possible to cleanly shut down the collector?

This is what I was hoping to do, but it's not possible with the API today to shutdown the collector and then get its stats out. We could make the shutdown method return the current stats, possibly?

I think this is at least worth a second look - shutdown returning any relevant state seems perfectly reasonable (and particularly useful for tests like this one). If this is hard or messy I wouldn't spend a ton of time on it, but it feels a lot nicer than having to allow for off-by-one tests.

@bnaecker bnaecker Dec 19, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think we'll have the same problem in this case. It's possible that the shutdown message is received and processed before the results are forwarded from the inner collection task to the outer one. We'll still have the possibility of an off-by-one between the server and the collection task.

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.

Oh, yeah, fair point.

@bnaecker
bnaecker merged commit c5dc896 into main Dec 19, 2024
@bnaecker
bnaecker deleted the fix-oximeter-self-stat-race branch December 19, 2024 19:06
jgallagher added a commit that referenced this pull request Feb 4, 2025
#7262 tried to fix the off-by-one test flake #7255, but it's still
around. I think based on discussion on that PR
(https://github.com/oxidecomputer/omicron/pull/7262/files#r1890548730),
the assertion in it was adding one to the wrong side: it's possible the
fake server may have seen one more request than the agent has finished
noting, which means `server_count` may be equal to either `count` or
`count + 1`, not `count` or `count - 1`.

The change from `assert_eq` to `assert` also caused the new flakes to
not log the actual values; this puts them back into the assertion
message in case this fix is still not quite right.
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.

test failed in CI: oximeter_collector::agent::tests::test_self_stat_error_counter

2 participants