Page MenuHomePhabricator

[services] Tunnelbroker - Adding delivering of undelivered messages from the database to the messages stream
ClosedPublic

Authored by max on Nov 6 2022, 6:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 1:14 AM
Unknown Object (File)
Wed, Dec 4, 4:16 PM
Unknown Object (File)
Tue, Nov 26, 7:07 AM
Unknown Object (File)
Tue, Nov 26, 12:46 AM
Unknown Object (File)
Nov 22 2024, 5:13 PM
Unknown Object (File)
Nov 22 2024, 4:15 PM
Unknown Object (File)
Nov 22 2024, 11:56 AM
Unknown Object (File)
Nov 21 2024, 5:49 AM

Details

Summary

This diff adds delivery of the undelivered messages from the database to the client when connecting to the bidirectional stream.
When the client is offline the messages to deliver are stored in the database. Right after the client is online and connected to the messages bidirectional stream we will deliver messages from the database to the client as messagesToDeliver.

The client will process messages and send back processed messages IDs to the Tunnelbroker as processedMessages only after that, we will delete messages from the database.

Removing of processed messages implemented in D5584.

Linear task: ENG-2060

Test Plan
  1. Insert a message into the messages table with the corresponding deviceID in the toDeviceID field.
  2. Connect by the gRPC client to the bidirectional stream with the sessionID corresponding to the deviceID in metadata.

The expected result is that the message from the database would be delivered to the client as the MessagesToDeliver.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max held this revision as a draft.

Rebasing on parent changes.

max retitled this revision from [services] Tunnelbroker - Adding delivering undelivered messages from the database in gRPC to [services] Tunnelbroker - Adding delivering of undelivered messages from the database to the messages stream.Nov 9 2022, 2:26 AM
max removed a reviewer: jon.
max edited the test plan for this revision. (Show Details)
max added reviewers: varun, marcin. max added 1 blocking reviewer(s): jon.
max published this revision for review.Nov 9 2022, 7:24 AM
This revision is now accepted and ready to land.Nov 9 2022, 11:03 AM
This revision now requires review to proceed.Nov 10 2022, 2:16 AM
tomek requested changes to this revision.Nov 10 2022, 8:54 AM
tomek added inline comments.
services/tunnelbroker/src/server/mod.rs
161 ↗(On Diff #18251)

Could you explain why we're deleting all the messages from AMQP here?

176–182 ↗(On Diff #18251)

It seems like this message can get pretty large. Should we split the payload into multiple messages?

This revision now requires changes to proceed.Nov 10 2022, 8:54 AM
max marked 2 inline comments as done.
max added inline comments.
services/tunnelbroker/src/server/mod.rs
161 ↗(On Diff #18251)

Could you explain why we're deleting all the messages from AMQP here?

We are cleaning the queue for the certain deviceID exactly before starting to send the messages from the database to avoid the condition when the new AMQP message can be pushed during the database lookups and writing messages to the stream. If we are cleaning up the queue after the database and writing to the stream but before listening to the new messages we can lose this message. If we are doing this before we are not because when the client sends a message we are pushing it into the database first and then pushing the AMQP message. So we are sure that the message is in the database in we will consume it from the database anyway in case of this condition.

176–182 ↗(On Diff #18251)

It seems like this message can get pretty large. Should we split the payload into multiple messages?

We are storing blobs outside of the gRPC messages itself so there is highly unlikely that we are exceeding the 4Mb gRPC messages limit. But we can make this check. I've created a follow-up task. Thanks, @tomek !

tomek added inline comments.
services/tunnelbroker/src/server/mod.rs
176–182 ↗(On Diff #18251)

Thanks! Added a comment there.

This revision is now accepted and ready to land.Nov 17 2022, 2:26 AM
max marked 2 inline comments as done.

Rebasing on parent changes.

This revision was landed with ongoing or failed builds.Nov 21 2022, 5:47 AM
This revision was automatically updated to reflect the committed changes.