Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor concurrency in scaler requestCounts function #286

Closed
arschles opened this issue Oct 7, 2021 · 0 comments · Fixed by #291
Closed

Refactor concurrency in scaler requestCounts function #286

arschles opened this issue Oct 7, 2021 · 0 comments · Fixed by #291
Labels
bug Something isn't working testing
Milestone

Comments

@arschles
Copy link
Collaborator

arschles commented Oct 7, 2021

The requestCounts function in the scaler has "funky" concurrency:

  • It starts up one goroutine per interceptor endpoint inside an errgroup. Each of these tries to send that interceptor's counts on a channel called countsCh
  • It starts up one final goroutine that ranges over the same countsCh channel
  • countsCh is closed in a defer

This design means that, when requestCounts returns, none of the updates are processed because everything is waiting for the defer close(countsCh). The updates will happen after it returns. This behavior means that updates to an interceptor might not be viewable immediately after requestCounts completes, and that's confusing.

Use-Case

When code calls requestCounts, it should be able to observe updates to all counts within the queue pinger immediately after that function returns.

Specification

  • Refactor requestCounts to update all counts before it returns
  • Write tests that call requestCounts directly
  • The queue pinger should not start the background goroutine in its constructor. A separate function call should be required for that.

Tell us in detail how this feature should work

@arschles arschles changed the title Fix concurrency in scaler requestCounts function Refactor concurrency in scaler requestCounts function Oct 7, 2021
@arschles arschles added the bug Something isn't working label Oct 7, 2021
@arschles arschles modified the milestones: v0.3.0, v0.2.0 Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant