Page MenuHomePhabricator

[services] Tunnelbroker - Add `waitUntilReady` function in AmqpManager
ClosedPublic

Authored by max on Aug 4 2022, 10:50 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 15, 8:00 AM
Unknown Object (File)
Sun, Dec 15, 8:00 AM
Unknown Object (File)
Sun, Dec 15, 8:00 AM
Unknown Object (File)
Sun, Dec 15, 8:00 AM
Unknown Object (File)
Sun, Dec 15, 7:49 AM
Unknown Object (File)
Nov 26 2024, 4:00 PM
Unknown Object (File)
Nov 22 2024, 11:24 PM
Unknown Object (File)
Nov 22 2024, 11:17 PM

Details

Summary

This diff is a part of the stack to fix the AMQP client reconnection issue.

The waitUntilReady function handles waiting for reconnection. This function uses on send() and ack() methods which send and acknowledge the message correspondingly.
The expected behavior is that we must wait while the connection/channel became available instead of returning an error immediately and stopping the execution.

Related linear task: ENG-1495

Test Plan

Successfully built using yarn run-tunnelbroker-service-in-sandbox command.
Passing all AMQP unit tests in the last diff D4749 in a stack.

Diff Detail

Repository
rCOMM Comm
Branch
add-waitUntilReady-to-AmqpManager
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

max held this revision as a draft.
max edited the test plan for this revision. (Show Details)
max added reviewers: karol, tomek.
max published this revision for review.Aug 4 2022, 4:51 PM
max edited the test plan for this revision. (Show Details)
tomek requested changes to this revision.Aug 5 2022, 5:53 AM

I don't think that this is the correct way of waiting for this condition to occur. First of all, it might never happen as access to amqpReady isn't synchronized. We should probably use some concurrency primitives rather than a sleep.

This revision now requires changes to proceed.Aug 5 2022, 5:53 AM
In D4741#136854, @tomek wrote:

I don't think that this is the correct way of waiting for this condition to occur. First of all, it might never happen as access to amqpReady isn't synchronized.

std::atomic<bool> amqpReady is an atomic variable and thread-safe and synchronized on the onReady, onError events in a follow-up D4744 diff (D4744 fixes the reconnection logic). This change needs to be projected as a part of the stack.

We should probably use some concurrency primitives rather than sleep.

We can use conditional variables for that for example or something like that, but it doesn't make sense to overengineering here because we will wait for a reconnection interval anyway and just check after it (please look at the D4744 part of the stack). It will make sense when we will use a variation timeout in a follow-up ENG-1381. So it can be part of these future changes.

tomek added inline comments.
services/tunnelbroker/src/Amqp/AmqpManager.cpp
153–160

Can we simplify it?

This revision is now accepted and ready to land.Aug 9 2022, 9:11 AM

Rebase on master changes.
Simplify while loop.

max added inline comments.
services/tunnelbroker/src/Amqp/AmqpManager.cpp
153–160

Can we simplify it?

Sure! Nice catch, thanks!

This revision was landed with ongoing or failed builds.Aug 22 2022, 6:37 AM
This revision was automatically updated to reflect the committed changes.
max marked an inline comment as done.
services/tunnelbroker/src/Amqp/AmqpManager.cpp
144–146 ↗(On Diff #15814)

This probably can be just removed

max added inline comments.
services/tunnelbroker/src/Amqp/AmqpManager.cpp
144–146 ↗(On Diff #15814)

This probably can be just removed

Yes, definitely! I've missed this and this diff is already landed.
That's why I've created a tiny diff to fix this. Sorry about that, we have a race condition for this comment ).