-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JetStream: Implement MaxAckPendingPerSubject #7910
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
base: main
Are you sure you want to change the base?
Changes from all commits
4c9bf1e
b11c5a4
5f45fae
e91e20d
b220978
c055882
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12475,7 +12475,7 @@ func (o *consumerFileStore) HasState() bool { | |
| } | ||
|
|
||
| // UpdateDelivered is called whenever a new message has been delivered. | ||
| func (o *consumerFileStore) UpdateDelivered(dseq, sseq, dc uint64, ts int64) error { | ||
| func (o *consumerFileStore) UpdateDelivered(dseq, sseq, dc uint64, ts int64, subj string) error { | ||
| o.mu.Lock() | ||
| defer o.mu.Unlock() | ||
|
|
||
|
|
@@ -12503,7 +12503,7 @@ func (o *consumerFileStore) UpdateDelivered(dseq, sseq, dc uint64, ts int64) err | |
| } | ||
| } else { | ||
| // Add to pending. | ||
| o.state.Pending[sseq] = &Pending{dseq, ts} | ||
| o.state.Pending[sseq] = &Pending{dseq, ts, subj} | ||
| } | ||
| // Update delivered as needed. | ||
| if dseq > o.state.Delivered.Consumer { | ||
|
|
@@ -12665,7 +12665,7 @@ func (o *consumerFileStore) Update(state *ConsumerState) error { | |
| if len(state.Pending) > 0 { | ||
| pending = make(map[uint64]*Pending, len(state.Pending)) | ||
| for seq, p := range state.Pending { | ||
| pending[seq] = &Pending{p.Sequence, p.Timestamp} | ||
| pending[seq] = &Pending{p.Sequence, p.Timestamp, p.Subject} | ||
| if seq <= state.AckFloor.Stream || seq > state.Delivered.Stream { | ||
| return fmt.Errorf("bad pending entry, sequence [%d] out of range", seq) | ||
| } | ||
|
|
@@ -12714,7 +12714,7 @@ func (o *consumerFileStore) ForceUpdate(state *ConsumerState) error { | |
| if len(state.Pending) > 0 { | ||
| pending = make(map[uint64]*Pending, len(state.Pending)) | ||
| for seq, p := range state.Pending { | ||
| pending[seq] = &Pending{p.Sequence, p.Timestamp} | ||
| pending[seq] = &Pending{p.Sequence, p.Timestamp, p.Subject} | ||
| if seq <= state.AckFloor.Stream || seq > state.Delivered.Stream { | ||
| return fmt.Errorf("bad pending entry, sequence [%d] out of range", seq) | ||
| } | ||
|
|
@@ -12896,7 +12896,7 @@ func checkConsumerHeader(hdr []byte) (uint8, error) { | |
| func (o *consumerFileStore) copyPending() map[uint64]*Pending { | ||
| pending := make(map[uint64]*Pending, len(o.state.Pending)) | ||
| for seq, p := range o.state.Pending { | ||
| pending[seq] = &Pending{p.Sequence, p.Timestamp} | ||
| pending[seq] = &Pending{p.Sequence, p.Timestamp, p.Subject} | ||
| } | ||
| return pending | ||
| } | ||
|
|
@@ -12993,7 +12993,7 @@ func (o *consumerFileStore) stateWithCopyLocked(doCopy bool) (*ConsumerState, er | |
| if doCopy { | ||
| o.state.Pending = make(map[uint64]*Pending, len(state.Pending)) | ||
| for seq, p := range state.Pending { | ||
| o.state.Pending[seq] = &Pending{p.Sequence, p.Timestamp} | ||
| o.state.Pending[seq] = &Pending{p.Sequence, p.Timestamp, p.Subject} | ||
| } | ||
| } else { | ||
| o.state.Pending = state.Pending | ||
|
|
@@ -13119,7 +13119,7 @@ func decodeConsumerState(buf []byte) (*ConsumerState, error) { | |
| ts = (mints - ts) * int64(time.Second) | ||
| } | ||
| // Store in pending. | ||
| state.Pending[sseq] = &Pending{dseq, ts} | ||
| state.Pending[sseq] = &Pending{dseq, ts, _EMPTY_} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Recovered pending entries are forced to Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
|
|
||
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 path now always rewrites
state.Pending[sseq]even whensseqwas already delivered, replacing the original consumer delivery sequence with the redelivery sequence.UpdateAcks()depends onp.Sequencestaying original to advance ack floors correctly, so file-backed consumers can end up with incorrect ack-floor progression and persisted pending state after redeliveries.Useful? React with 👍 / 👎.