Skip to content

Avoid pruning oximeter producers registered during a refresh - #6905

Closed
bnaecker wants to merge 1 commit into
mainfrom
track-oximeter-producer-generations
Closed

bnaecker wants to merge 1 commit into
mainfrom
track-oximeter-producer-generations

Conversation

@bnaecker

Copy link
Copy Markdown
Collaborator

- Add generation numbers to the collection of oximeter producers, and
  assign the currrent generation to each producer as it is registered.
- Modify the refresh method to first take the generation number before
  starting to list current producers. Then use that to avoid pruning
  producers that are _new_ since we started refreshing our list.
- Fixes #6895 and possibly #6901
@bnaecker

Copy link
Copy Markdown
Collaborator Author

I'd really like a close review on this one. It is extremely difficult to trigger this flaky behavior, since we need to start a server pretending to be Nexus; interrupt a request to refresh the producer list; and concurrently register a new producer as the same time. The test would then assert that we've not pruned that concurrently-registered producer.

I spent most of the day trying and failing to test this, but could not come up with an approach that reliably triggers the bug. Given that we're trying to reduce test flakes, I'm very hesitant to add a new test that would itself be flaky. I think I've got the logic on bumping the generation numbers correctly, anytime we modify the map of producers, but I could definitely use other, more experienced eyes.

@bnaecker

Copy link
Copy Markdown
Collaborator Author

@jgallagher, @davepacheco and I spent a bit of time yesterday talking about this change, and we ultimately decided to close it unmerged and make a more significant change to the interfaces between Nexus and oximeter.

The bug this was intended to address comes about because there are two ways oximeter learns about producers: it periodically refreshes its entire list from Nexus, and Nexus may notify it directly of a new producer at the time that it registers. If the direct registration happens during the periodic refresh, that new producer is not in the paginated list, and so it's immediately registered and deleted after the refresh completes.

Taking a step back, what we're trying to do here is sync a changing set from Nexus to oximeter. We can do that in a few different ways:

  • Nexus can push the entire list
  • oximeter can pull the entire list
  • Nexus can notify oximeter of a new producer, or that there are new producers

There are probably others, and they all have tradeoffs. Today we're doing both 2 and 3. Instead, we've decided to settle just on 2: oximeter should just pull its entire list periodically.

This has some tradeoffs. First, the benefits are that it's very simple; the amount of work is constant and very predictable; it's easy to test and actually reduces the number of API calls in the system. That's because we're removing the one where Nexus notifies oximeter of a new producer. The main downside here is latency. Today, when a producer registers, it is basically registered right away with Nexus and oximeter. In this new approach, oximeter will not become aware of the new producer until its next refresh. On the other hand, we can basically just tune this interval to be "small enough".

The downsides of the other approaches seemed more problematic. Having Nexus push the data means a new background task and a new interface from Nexus to oximeter. That interface is something we've been trying to minimize and avoid adding new instances of, since it complicates upgrading these different components since there is a dependency arrow pointing in both directions. The last option is OK, but isn't really enough -- if oximeter restarts, it needs to fetch the whole list anyway. Having one route to doing that is simpler, easier to test and sufficient to solve the problem (at the cost of the latency discussed above).

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: integration_tests::metrics::test_metrics

1 participant