Repository navigation
Spawn a task in oximeter to actually do the collection - #7097
Conversation
`oximeter` currently starts up a task for each producer. When their collection interval expires, that task directly makes an HTTP request to the producer to collect its data, _in-line_ in the same task. This can cause problems, especially if there are concurrent updates to the producer's address information. The main `oximeter` HTTP server will send a message to that task in that case, asking it to update its producer information, but that task might be off in lalaland making an HTTP request. This is particularly bad since that HTTP request may never complete -- the producer's address might be updated, so the old one is defunct, possibly forever! This commit addresses this by spawning a new task to actually run the collection itself. This keeps the first-level task alive and responsive, such that it can abort any previously-spawned collections if there are updates. We _also_ replace any existing task if a collection was explicitly requested, but we ignore existing collections (rather than spawning a new one) if the timer expires while one is already running. This resolves test flakes described in #6901.
|
Some of the self-stat counter tests are failing, e.g., here. These have always been a bit flaky, so I'm not that surprised that adding another layer of spawning has made them more so. I've set up a small run-loop locally, which just runs these failing tests in a loop until they fail. I can get them both to fall over within about a minute, usually around 60 runs. I'm going to fix them in this PR. The whole point of this is to remove a test flake, so that'd be pretty annoying to introduce more flakes :) I've taken a page from @jgallagher's book, and created a small test Dropshot server in place of the |
|
@jgallagher and I chatted at length about this. I'm going to push some big changes to this branch, but the summary is:
|
- Remove the previous, hacky manual `Future` that represented a spawned collection task. Instead, spawn a new long-running task that we communicate with to do the collections, which can be interrupted with an update to the producer endpoint if needed. - Separate queues for timer-based and forced / triggered collections. Each has a queue depth of 1 currently, but we handle full queues differently. For force-collections, we return an error back to the caller in this case -- the assumption is that this shouldn't happen, since it's always used in test code, and we want to fail the collection entirely. For timer-based collections, we bump a new failure counter and log an error, and then let the queued collections operate as usual. - Rename `Oximeter::force_collect()` to `Oximeter::try_force_collect()` and make it fallible to reflect the possibility of a queue-full error
jgallagher
left a comment
There was a problem hiding this comment.
LGTM, thanks! This was quite a bit of work. I'm a little worried we've still missed some edge case, but there's a lot of logging in here so if so, hopefully it's easy to identify.
|
Thanks for the review @jgallagher!
I've been waffling on adding a lot more tests here. The upshot of separating the two tasks out is that it should be easier to test them in isolation. Do you think it's worthwhile to do that? I don't want to bloat the PR, but now that we've seen a few pretty nasty bugs in this file, it seems like a good investment. |
- Send error if we fail to send a force-collection request because the channel is closed - Rework joining all the force-collection futures to ensure they all run - Copy producer endpoint rather than clone
oximetercurrently starts up a task for each producer. When their collection interval expires, that task directly makes an HTTP request to the producer to collect its data, in-line in the same task. This can cause problems, especially if there are concurrent updates to the producer's address information. The mainoximeterHTTP server will send a message to that task in that case, asking it to update its producer information, but that task might be off in lalaland making an HTTP request. This is particularly bad since that HTTP request may never complete -- the producer's address might be updated, so the old one is defunct, possibly forever!This commit addresses this by spawning a new task to actually run the collection itself. This keeps the first-level task alive and responsive, such that it can abort any previously-spawned collections if there are updates. We also replace any existing task if a collection was explicitly requested, but we ignore existing collections (rather than spawning a new one) if the timer expires while one is already running.
This resolves test flakes described in #6901.