HomePhabricator
Diffusion Comm c3089d0e93e1

[services] Tunnelbroker - Add AMQP shared channel locking

Description

[services] Tunnelbroker - Add AMQP shared channel locking

Summary:
Following comments in D4740 from the synchronization question and forward, ENG-1495 task, we should use a synchronization mechanism in access to the AMQP Client channel which is accessed from the different threads (gRPC threads + DeliveryBroker thread) by calling send() and ack() methods.
When the number of threads grows non-synchronized access to the shared channel causes a segmentation fault or AMQP-CPP TCP Connection buffer error.

This diff introduces the use of C++17 std::scoped_lock which provides a convenient RAII-style mechanism for owning a shared channel.
Usage of the std::scoped_lock was added to the send() and ack() methods which are called from the threads.

Related Linear task: ENG-1495

Test Plan: Successfully pass a stress test in D4768 with multiple threads sending messages at once.

Reviewers: karol, tomek

Reviewed By: tomek

Subscribers: jon, ashoat, tomek, adrian, atul, karol, abosh

Differential Revision: https://phab.comm.dev/D4767

Details

Provenance
maxAuthored on Aug 6 2022, 11:12 AM
Reviewer
tomek
Differential Revision
D4767: [services] Tunnelbroker - Add AMQP shared channel locking
Parents
rCOMM6b6d2067a16f: [services] Tunnelbroker - Fix `amqpReady` assignment
Branches
Unknown
Tags
Unknown