MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / releaseUnusedSequenceRange

Method releaseUnusedSequenceRange

db/change_cache.go:619–648  ·  view source on GitHub ↗

releaseUnusedSequenceRange will handle unused sequence range arriving over DCP. It will batch remove from skipped or push a range to pending sequences, or both.

(ctx context.Context, fromSequence uint64, toSequence uint64, timeReceived channels.FeedTimestamp)

Source from the content-addressed store, hash-verified

617// releaseUnusedSequenceRange will handle unused sequence range arriving over DCP. It will batch remove from skipped or
618// push a range to pending sequences, or both.
619func (c *changeCache) releaseUnusedSequenceRange(ctx context.Context, fromSequence uint64, toSequence uint64, timeReceived channels.FeedTimestamp) {
620
621 base.InfofCtx(ctx, base.KeyCache, "Received #%d-#%d (unused sequence range)", fromSequence, toSequence)
622
623 allChangedChannels := channels.SetOfNoValidate(unusedSeqChannelID)
624
625 // if range is single value, just run sequence through process entry and return early
626 if fromSequence == toSequence {
627 change := &LogEntry{
628 Sequence: toSequence,
629 TimeReceived: timeReceived,
630 UnusedSequence: true,
631 }
632 changedChannels := c.processEntry(ctx, change)
633 channelSet := channels.SetFromArrayNoValidate(changedChannels)
634 allChangedChannels = allChangedChannels.Update(channelSet)
635 if c.notifyChangeFunc != nil {
636 c.notifyChangeFunc(ctx, allChangedChannels)
637 }
638 return
639 }
640
641 // push unused range to either pending or skipped lists based on current state of the change cache
642 changedChannels := c.processUnusedRange(ctx, fromSequence, toSequence, timeReceived)
643 allChangedChannels = allChangedChannels.Update(channels.SetFromArrayNoValidate(changedChannels))
644
645 if c.notifyChangeFunc != nil {
646 c.notifyChangeFunc(ctx, allChangedChannels)
647 }
648}
649
650// processUnusedRange handles pushing unused range to pending or skipped lists
651func (c *changeCache) processUnusedRange(ctx context.Context, fromSequence, toSequence uint64, timeReceived channels.FeedTimestamp) []channels.ID {

Calls 6

processEntryMethod · 0.95
processUnusedRangeMethod · 0.95
InfofCtxFunction · 0.92
SetOfNoValidateFunction · 0.92
SetFromArrayNoValidateFunction · 0.92
UpdateMethod · 0.45