Skip to content

[4.1.0.1 backport] CBG-5550: Revert "CBG-5262 fix missing changes with active_only=true and limit="#8418

Merged
adamcfraser merged 1 commit into
release/4.1.0.1from
CBG-5550
Jul 6, 2026
Merged

[4.1.0.1 backport] CBG-5550: Revert "CBG-5262 fix missing changes with active_only=true and limit="#8418
adamcfraser merged 1 commit into
release/4.1.0.1from
CBG-5550

Conversation

@torcolvin

Copy link
Copy Markdown
Collaborator

[4.1.0.1 backport] CBG-5550: Revert "CBG-5262 fix missing changes with active_only=true and limit="

cherry-pick of 7a6a76f

…h active_only=true and limit= (#8416)

cherry-pick of 7a6a76f
Copilot AI review requested due to automatic review settings July 6, 2026 01:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This backport PR reverts a prior change related to / _changes behavior when active_only=true is used together with limit, specifically in the channel-cache path used by Sync Gateway’s changes feed.

Changes:

  • Removes channel-cache unit tests that exercised ActiveOnly + Limit scenarios.
  • Reverts singleChannelCacheImpl.GetChanges behavior to stop appending cache results when the query result has already met the limit (based on raw row count).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
db/channel_cache_test.go Deletes regression tests for ActiveOnly + Limit channel-cache scenarios (and the helper used by them).
db/channel_cache_single.go Reverts cache/query merge logic, changing when cached entries are appended and how the limit is applied.

Comment on lines 442 to 451
room := options.Limit - len(result)
if (options.Limit == 0 || room > 0 || options.ActiveOnly) && len(resultFromCache) > 0 {
if (options.Limit == 0 || room > 0) && len(resultFromCache) > 0 {
// Concatenate the view & cache results:
if len(result) > 0 && resultFromCache[0].Sequence == result[len(result)-1].Sequence {
resultFromCache = resultFromCache[1:]
}
n := len(resultFromCache)
// Limit evaluation only valid when not activeOnly, since view and cache results don't apply activeOnly filtering
if !options.ActiveOnly {
if options.Limit > 0 && room > 0 && room < n {
n = room
}
if options.Limit > 0 && room > 0 && room < n {
n = room
}
Comment thread db/channel_cache_test.go
Comment on lines 592 to 600
cache, err := newChannelCache(base.TestCtx(t), "testDb", options, queryHandler.asFactory, activeChannels, testStats)
assert.Error(t, err, "Background task error whilst creating channel cache")
assert.Nil(t, cache)

backgroundTaskError, ok := err.(*BackgroundTaskError)
require.True(t, ok)
assert.Equal(t, "CleanAgedItems", backgroundTaskError.TaskName)
assert.Equal(t, options.ChannelCacheAge, backgroundTaskError.Interval)
}
@adamcfraser adamcfraser merged commit f10e6d3 into release/4.1.0.1 Jul 6, 2026
62 of 63 checks passed
@adamcfraser adamcfraser deleted the CBG-5550 branch July 6, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants