Skip to content

Comments

CBG-4286 separate feed name from checkpoint prefix#8073

Open
torcolvin wants to merge 2 commits intomainfrom
CBG-4286-take2
Open

CBG-4286 separate feed name from checkpoint prefix#8073
torcolvin wants to merge 2 commits intomainfrom
CBG-4286-take2

Conversation

@torcolvin
Copy link
Collaborator

@torcolvin torcolvin commented Feb 18, 2026

CBG-4286 separate feed name from checkpoint prefix

The only behavior change is that https://github.com/couchbase/sync_gateway/blob/main/base/dcp_client_worker.go#L149 will ignore the given DCP client's checkpoint prefix rather than something that is closer to _sync:dcp_ck. I can restore this behavior but I'm not super worried about it in practice since we only persist metadata periodically anyway.

Please do a careful review to see if I've accidentally changed the checkpoint prefixes, but this is why I wrote 4717efb

The feed name is only visible via cbcollect. It needs to be:

  • unique for each DCPAgent that opens, or else kv will drop the connection. Hence appending UUID
  • less than 200 characters
  • should have a meaningful matching prefix to find SG feeds in a cbcollect
DCP User DCP Client type Use checkpoints Affected by Code Pathway Checkpoint Frequency
EE import cbgt 1m
CE import GoCBDCPClient does not effectively use checkpoints due to CBG-5144 1m
resync GoCBDCPClient 30s
attachment migration GoCBDCPClient 30s
attachment compaction GoCBDCPClient 30s
caching feed GoCBDCPClient

Only the code that uses GoCBDCPClient with meaningful checkpoints has a very small behavioral change with the code. In this case, if you were running a feed with checkpoints at the same time as another feed, it would previously ignore the other feed's checkpoint documents and a callback. In practice, the callbacks return immediately for _sync documents so this is pretty much a no-op.

The concern in the code is making sure that the GoCBDCPClient did not change checkpoint names since we wish to resume a DCP feed across a version update.

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Integration Tests

Copilot AI review requested due to automatic review settings February 18, 2026 22:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors DCP client initialization to separate the feed name (used for DCP stream naming) from the checkpoint prefix (used for checkpoint document naming). Previously, these were conflated, with the feed ID being appended to the checkpoint prefix within the DCP client. Now, the FeedID and CheckpointPrefix are independent fields in DCPClientOptions.

Changes:

  • Introduced FeedID field in DCPClientOptions for generating unique DCP stream names
  • Modified checkpoint prefix generation to include complete paths at the call site
  • Converted attachment compaction phase constants to a typed constant for better type safety
  • Updated all DCP client creation sites to provide explicit FeedID and CheckpointPrefix values

Reviewed changes

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

Show a summary per file
File Description
base/gocb_dcp_client.go Added FeedID field to DCPClientOptions, removed ID parameter from NewDCPClient, generate stream name from FeedID inside the client
base/dcp_common.go Added length validation for generated DCP stream names (max 200 characters)
base/gocb_dcp_feed.go Removed feedName parameter from NewDCPClient call (but missing FeedID in options)
base/dcp_client_test.go Updated all test calls to remove feedID parameter from NewDCPClient
db/attachment_compaction.go Introduced attachmentCompactionPhase type, updated functions to use FeedID and complete checkpoint prefix, removed GenerateCompactionDCPStreamName
db/attachment_compaction_test.go Updated to use new getCompactionDCPClientOptions signature (but has compilation error)
db/background_mgr_resync_dcp.go Updated to use FeedID and complete checkpoint prefix, renamed GenerateResyncDCPStreamName to GetResyncDCPCheckpointPrefix
db/background_mgr_resync_dcp_test.go Updated test to use new function signature
db/background_mgr_attachment_migration.go Updated to use FeedID and complete checkpoint prefix, removed GenerateAttachmentMigrationDCPStreamName
db/background_mgr_attachment_migration_test.go Updated test to use new function signature
db/background_mgr_attachment_compaction.go Updated parameter type to attachmentCompactionPhase for better type safety
db/util_testing.go Added FeedID to purge DCP client options
rest/attachmentcompactiontest/attachment_compaction_api_test.go Updated to use new checkpoint prefix function (but has type mismatch issue)
rest/adminapitest/resync_test.go Updated to use new checkpoint prefix function
tools/cache_perf_tool/dcpDataGeneration.go Added FeedID to test DCP client options, removed feedID parameter from NewDCPClientForTest

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.

2 participants