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

EdgeHub: Fix MessageStore initial offset after restart #603

Merged
merged 4 commits into from
Dec 5, 2018

Conversation

varunpuranik
Copy link
Contributor

EdgeHub Message store contains queues for each endpoint. 3 pointer values are maintained - head, tail, and checkpoint (where the last processed pointer was).
Of these head and tail are computed from the queue, and checkpoint is persisted.
However, in a situation where all messages are processed and cleaned up, the queue will be empty and checkpointer will be pointing to the last processed value (say 1600).
If at this point the EdgeHub is restarted, the initialized values will be -
head =0, tail = -1 and checkpoint = 1600.
This PR fixes the issue, so that the initialization values are -
head = 1600, tail = 1599, checkpoint = 1600.

@@ -13,6 +14,7 @@ public static long GetOffsetFromKey(byte[] key)
Preconditions.CheckNotNull(key, nameof(key));
if (BitConverter.IsLittleEndian)
{
key = key.ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this change for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, to convert the key to offset (byte array to offset, we need to reverse the byte array if the arch is little endian. But we don't want to affect the original byte array. So ToArray creates a copy of it. (I will add a comment saying so).

@myagley myagley merged commit 81f93dc into master Dec 5, 2018
@myagley myagley deleted the varunpuranik/fixmso1 branch December 5, 2018 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants