Skip to content

[IMPROVED] Optimizations for PurgeEx from KV PurgeDeletes() clients. #6801

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

Merged
merged 6 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4329,7 +4329,7 @@ func sliceHeader(key string, hdr []byte) []byte {
if len(hdr) == 0 {
return nil
}
index := bytes.Index(hdr, []byte(key))
index := bytes.Index(hdr, stringToBytes(key))
hdrLen := len(hdr)
// Check that we have enough characters, this will handle the -1 case of the key not
// being found and will also handle not having enough characters for trailing CRLF.
Expand Down
30 changes: 8 additions & 22 deletions server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5322,9 +5322,6 @@ func (o *consumer) selectStartingSeqNo() {
if mmp == 1 {
o.sseq = state.FirstSeq
} else {
// A threshold for when we switch from get last msg to subjects state.
const numSubjectsThresh = 256
lss := &lastSeqSkipList{resume: state.LastSeq}
var filters []string
if o.subjf == nil {
filters = append(filters, o.cfg.FilterSubject)
Expand All @@ -5333,24 +5330,10 @@ func (o *consumer) selectStartingSeqNo() {
filters = append(filters, filter.subject)
}
}
for _, filter := range filters {
if st := o.mset.store.SubjectsTotals(filter); len(st) < numSubjectsThresh {
var smv StoreMsg
for subj := range st {
if sm, err := o.mset.store.LoadLastMsg(subj, &smv); err == nil {
lss.seqs = append(lss.seqs, sm.seq)
}
}
} else if mss := o.mset.store.SubjectsState(filter); len(mss) > 0 {
for _, ss := range mss {
lss.seqs = append(lss.seqs, ss.Last)
}
}
}
// Sort the skip list if needed.
if len(lss.seqs) > 1 {
slices.Sort(lss.seqs)
}

lss := &lastSeqSkipList{resume: state.LastSeq}
lss.seqs, _ = o.mset.store.MultiLastSeqs(filters, 0, 0)

if len(lss.seqs) == 0 {
o.sseq = state.LastSeq
} else {
Expand Down Expand Up @@ -5874,7 +5857,10 @@ func (o *consumer) decStreamPending(sseq uint64, subj string) {

// Check if this message was pending.
p, wasPending := o.pending[sseq]
rdc := o.deliveryCount(sseq)
var rdc uint64
if wasPending {
rdc = o.deliveryCount(sseq)
}

o.mu.Unlock()

Expand Down
Loading
Loading