-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[FIXED] Subject state consistency #6226
Conversation
@@ -2614,10 +2614,6 @@ func (fs *fileStore) numFilteredPendingWithLast(filter string, last bool, ss *Si | |||
// Always reset. | |||
ss.First, ss.Last, ss.Msgs = 0, 0, 0 | |||
|
|||
if filter == _EMPTY_ { |
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 is redundant, if isAll := filter == _EMPTY_ || filter == fwcs
we early return above.
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.
LGTM
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
06983f6
to
283b607
Compare
@@ -7502,6 +7498,9 @@ func (fs *fileStore) Compact(seq uint64) (uint64, error) { | |||
// Update fss | |||
smb.removeSeqPerSubject(sm.subj, mseq) | |||
fs.removePerSubject(sm.subj) | |||
// Need to mark the sequence as deleted. Otherwise, recalculating ss.First | |||
// for per-subject info would be able to find it still. | |||
smb.dmap.Insert(mseq) |
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.
Another important addition; TestFileStoreExpireMsgsOnStart
was failing as it relied on the bug existing. Now that the bug is gone, we need to actually mark the sequence as deleted. Otherwise, mb.recalculateFirstForSubj
could still find and select that sequence.
Subject state would not always remain consistent given a specific pattern of message removals. There were three bugs: - `recalculateFirstForSubj` in memstore would do `startSeq+1`, but filestore would always just start at `mb.first.seq`. These are now consistent. - `recalculateFirstForSubj` was not called when `ss.Msgs == 1`, which could mean we had a stale `ss.FirstSeq` if it needed to be recalculated. - If after recalculation it turns out `ss.FirstSeq` equals the message we're trying to remove, we need to `recalculateFirstForSubj` again, since `ss.Last` is also lazy and could be incorrect. Apart from that, filestore and memstore are now both equivalent when it comes to first updating per-subject state and then removing the message, as well as `removeSeqPerSubject` and how it updates the subject state. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
Subject state would not always remain consistent given a specific pattern of message removals. There were three bugs: - `recalculateFirstForSubj` in memstore would do `startSeq+1`, but filestore would always just start at `mb.first.seq`. These are now consistent. - `recalculateFirstForSubj` was not called when `ss.Msgs == 1`, which could mean we had a stale `ss.FirstSeq` if it needed to be recalculated. - If after recalculation it turns out `ss.FirstSeq` equals the message we're trying to remove, we need to `recalculateFirstForSubj` again, since `ss.Last` is also lazy and could be incorrect. Apart from that, filestore and memstore are now both equivalent when it comes to first updating per-subject state and then removing the message, as well as `removeSeqPerSubject` and how it updates the subject state. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
Subject state would not always remain consistent given a specific pattern of message removals.
There were three bugs:
recalculateFirstForSubj
in memstore would dostartSeq+1
, but filestore would always just start atmb.first.seq
. These are now consistent.recalculateFirstForSubj
was not called whenss.Msgs == 1
, which could mean we had a staless.FirstSeq
if it needed to be recalculated.ss.FirstSeq
equals the message we're trying to remove, we need torecalculateFirstForSubj
again, sincess.Last
is also lazy and could be incorrect.Apart from that, filestore and memstore are now both equivalent when it comes to first updating per-subject state and then removing the message, as well as
removeSeqPerSubject
and how it updates the subject state.Signed-off-by: Maurice van Veen github@mauricevanveen.com