Skip to content

Commit b49cac9

Browse files
committed
update comment and move call to oldest skipped to outside loop
1 parent 946fcea commit b49cac9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

db/change_cache.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,15 @@ func (c *changeCache) DocChanged(event sgbucket.FeedEvent) {
445445

446446
if len(syncData.RecentSequences) > 0 {
447447
nextSequence := c.getNextSequence()
448+
oldestSkipped := c.getOldestSkippedSequence(ctx)
448449

449450
for _, seq := range syncData.RecentSequences {
450-
// we need to check if it's possible that one of the recent sequences has been pushed to skipped
451-
isSkipped := seq < currentSequence && seq >= c.getOldestSkippedSequence(ctx)
451+
// seq < currentSequence means the sequence is not the latest allocated to this document
452+
// seq >= nextSequence means this sequence is a pending sequence to be expected in the cache
453+
// the two conditions above together means that the cache expect ue to run processEntry on this sequence as its pending
454+
// If seq >= c.getOldestSkippedSequence(ctx) and seq < current sequence allocated to the doc this means
455+
// that this sequence never arrived over the caching feed due to deduplication and was pushed to a skipped sequence list
456+
isSkipped := seq < currentSequence && seq >= oldestSkipped
452457
if (seq >= nextSequence && seq < currentSequence) || isSkipped {
453458
base.InfofCtx(ctx, base.KeyCache, "Received deduplicated #%d in recent_sequences property for (%q / %q)", seq, base.UD(docID), syncData.CurrentRev)
454459
change := &LogEntry{

0 commit comments

Comments
 (0)