fix: Avoid clearing updated keys on twin update#3570
Merged
albinsuresh merged 1 commit intothin-edge:mainfrom Apr 21, 2025
Merged
fix: Avoid clearing updated keys on twin update#3570albinsuresh merged 1 commit intothin-edge:mainfrom
albinsuresh merged 1 commit intothin-edge:mainfrom
Conversation
When existing twin data like {"a": 1, "b": 2, "c": 3} is updated with {"b": 2, "c": 4, "d": 5}
the update is handled as follows:
1. The removed key: "a" is cleared
2. The unchanged key: "b" is not republished
3. The updated key: "c" is republished with the new value 4
4. The new key: "d" is published as new
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Contributor
Robot Results
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug RCA
The test flakiness where the
twin/namefragment was becomingnullafter the same was updated with a new value because of a faulty logic in how twin updates are handled. When a given twin fragment is updated with a new value, instead of overwriting the existing value with the new one, the current code was trying to clear the old value with a null message first, followed by publishing the updated value. This is the cause of the race, as sometimes, thetwinquery in the test was happening immediately after thenullvalue is processed which results in empty response.Proposed changes
When existing twin data like {"a": 1, "b": 2, "c": 3} is updated with {"b": 2, "c": 4, "d": 5}, the update is handled as follows:
Types of changes
Paste Link to the issue
#3559
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments