fix: New Leader Risk Using Values Set By Prev Leader #281
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.
Consider the case where a leader node dies when trying to setCurrentVod in store. Since this is one of the last values written to store in a VOD_NEXT_INIT state, all other values like vodMediaSeq and mediaSeq are already updated at that point.
So when the follower node becomes the new leader node, it is to take over and perform the VOD_NEXT_INIT state itself. But it does not know if the mediaSeq value for example is from the new vod or the prev vod. It cannot make that distinction. What happens is that it loads the vod and stores a new mediaSeq as (old mediaSeq + old final-vodMediaSeq). But the issue here is that it is using the new mediaSeq value that the prev leader put in.
This results in the leader node creating a mediaSeq that is too large and the stream will have jumped MEDIA-SEQUENCE values equal to the number of mseqs in the prev VOD. This large jump could be confusing to players.
This PR will move up the set operation for the vod object in hopes for there to only be old sequence values in store should it have died/failed setting the new VOD in store.