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: Delay after publishing entity creation message #3446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/extensions/c8y_mapper_ext/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ impl C8yMapperActor {
self.process_registration_message(pending_entity.reg_message)
.await?;

// Wait for a while to allow the registration message to be processed by the cloud before sending the data messages
tokio::time::sleep(Duration::from_secs(1)).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it's going to break if the bridge loses connection. Is there a particular reason why we can't do what we do for the main device, i.e. publish the registration message multiple times and wait until we receive a suitable 41 response to confirm the device definitely exists?

Copy link
Contributor Author

@albinsuresh albinsuresh Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a known limitation. We're doing this low cost fix to just reduce the probability of this flakiness in 80-90% of the cases when everything is working fine. The plan was to try this fix first and see if it reduces the flakiness considerably.

The other two approaches considered were:

  1. Waiting for the duplicate device error over MQTT as done for the main device
  2. Performing the entity creation over HTTP

Since both approaches fundamentally change the control flow within the mapper, with huge impact on all existing tests(esp unit tests) as well, we just decided to do this minimal fix for now. But, we can revisit these approaches later once we achieve some stability.


// Convert and publish cached data messages
for pending_data_message in pending_entity.data_messages {
self.process_message(pending_data_message).await?;
Expand Down
Loading