-
Notifications
You must be signed in to change notification settings - Fork 57
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
base: main
Are you sure you want to change the base?
refactor: Delay after publishing entity creation message #3446
Conversation
Introduce a delay after the entity registration is converted and published to C8Y, to allow it to be processed by the cloud before sending any data messages. This reduces the probability of the data message racing with the registration message and auto-creating the target entity before the registration is processed.
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Robot Results
Failed Tests
|
@@ -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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- Waiting for the duplicate device error over MQTT as done for the main device
- 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.
Proposed changes
Introduce a delay after the entity registration is converted and published to C8Y, so that the telemetry data published afterwards doesn't race with it, leading to the auto-creation of a managed object with same ID.
Types of changes
Paste Link to the issue
#3439
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments