Skip to content

Conversation

@torcolvin
Copy link
Collaborator

CBG-5024 Remove non multisubdoc xattr support

Code cleanup of dead code pathways in post Sync Gateway 4.0. This does not do all the tasks described in CBG-5024 to make code review processes easier.

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 November 26, 2025 13:14
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 removes legacy code paths that supported non-multisubdoc xattr operations in Couchbase Server versions prior to 7.6. Since Sync Gateway 4.0+ requires CBS 7.6 or higher, the multisubdoc xattr feature is always available, eliminating the need for conditional logic and fallback mechanisms.

Key changes:

  • Removed EnableMou and UseMou() checks throughout the codebase
  • Simplified xattr operations by assuming multisubdoc support is always available
  • Cleaned up test code that conditionally skipped tests or used different code paths based on CBS version

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rest/importtest/import_test.go Removed test skip for multisubdoc feature check
db/util_testing.go Removed fallback code for single-xattr deletion in purgeWithDCPFeed
db/import_test.go Removed conditional logic for MOU xattr testing
db/import.go Removed useMou() conditional checks
db/database_collection.go Simplified xattr key collection and removed useMou() helper
db/database.go Removed EnableMou field, initialization, and UseMou() method
db/crud.go Removed useMou() check when writing MOU xattr
db/background_mgr_resync_dcp_test.go Removed test skip for multisubdoc feature check
base/collection_xattr_test.go Removed conditional test case additions based on multisubdoc support
base/collection_xattr.go Removed fallback logic for single/dual xattr operations
base/bucket_gocb_test.go Removed conditional test behavior based on multisubdoc support

Comment on lines +1850 to +1862
doc.MetadataOnlyUpdate = computeMetadataOnlyUpdate(doc.Cas, doc.RevSeqNo, doc.MetadataOnlyUpdate)

_, rawSyncXattr, rawVvXattr, rawMouXattr, rawGlobalXattr, err := updatedDoc.MarshalWithXattrs()
updatedDoc := sgbucket.UpdatedDoc{
Doc: nil, // Resync does not require document body update
Xattrs: map[string][]byte{
base.SyncXattrName: rawSyncXattr,
base.VvXattrName: rawVvXattr,
base.MouXattrName: rawMouXattr,
},
Expiry: updatedExpiry,
}
if db.useMou() {
updatedDoc.Xattrs[base.MouXattrName] = rawMouXattr
if doc.MetadataOnlyUpdate.HexCAS == expandMacroCASValueString {
updatedDoc.Spec = append(updatedDoc.Spec, sgbucket.NewMacroExpansionSpec(XattrMouCasPath(), sgbucket.MacroCas))
}
if doc.MetadataOnlyUpdate.HexCAS == expandMacroCASValueString {
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

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

The variable updatedDoc shadows the outer variable updatedDoc from line 1852. Consider renaming one of them (e.g., rename the sgbucket.UpdatedDoc to updatedDocData) to avoid confusion.

Copilot uses AI. Check for mistakes.
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