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

grpc-js: Fix call ref timer handling #2626

Merged

Conversation

murgatroid99
Copy link
Member

I think this change fixes the bug described in #2586 (comment).

The purpose of the callRefTimer is to hold the process open as long as there are calls that the channel is responsible for tracking because they are queued to either get a config from the resolver, or get a pick from the LB policy. Once a call becomes attached to a connection, that connection takes over tracking it and the responsibility for holding the process open. The general callRefTimer workflow goes like this:

  • An update comes in from either the resolver or the LB policy
  • The corresponding queue is emptied
  • The timer is unreffed
  • Each call is prompted to process that update
  • If any call needs to requeue, that will cause the timer to be reffed

Once a resolver update has been received, calls never queue for configs anymore, they get them immediately after being created. And calls only queue for picks once they have a config. So, there is never a case when both queues are in use at the same time. The problem before this change is that if an update comes in from the resolver after the initial resolver update while there are calls in the pick queue, the timer would be unreffed but there would be no calls in the config queue, so nothing would trigger reffing the timer again. The fix is to only unref the timer if there is at least one call in the queue to process. I added the same condition to all call sites for consistency.

@silentroach
Copy link

cool, thank you!

@murgatroid99 murgatroid99 merged commit 9890d59 into grpc:@grpc/grpc-js@1.9.x Dec 12, 2023
4 of 5 checks passed
@murgatroid99
Copy link
Member Author

@silentroach This change has been published in grpc-js 1.9.13

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.

None yet

3 participants