Skip to content

Comments

CBG-5170 change listener: don't process docs without xattr#8064

Open
torcolvin wants to merge 3 commits intomainfrom
CBG-5170
Open

CBG-5170 change listener: don't process docs without xattr#8064
torcolvin wants to merge 3 commits intomainfrom
CBG-5170

Conversation

@torcolvin
Copy link
Collaborator

CBG-5170 change listener: don't process docs without xattr

This avoids unmarshalling documents without _sync xattr, which was necessarily in pre-xattr mode. The change cache could see documents without _sync xattrs if they were not yet imported, or they got rejected by the import filter.

If this were to get backported to 3.3, you would add a check for db.UseXattrs() around this section.

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

@torcolvin torcolvin requested a review from gregns1 February 12, 2026 15:28
Copilot AI review requested due to automatic review settings February 12, 2026 15:28
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 enhances the change listener to skip processing documents without xattrs, improving performance by avoiding unnecessary unmarshalling operations. The change cache previously attempted to process documents lacking _sync xattrs (e.g., un-imported documents or those rejected by import filters), which was only necessary in pre-xattr mode.

Changes:

  • Add early return when documents lack xattrs, preventing unnecessary processing
  • Reorder validation checks to filter out documents without xattrs before attempting unmarshalling
  • Remove obsolete error logging for binary documents that are now filtered earlier

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

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

Comment on lines +372 to +373
// If this is a binary document, we can ignore.
if event.DataType == base.MemcachedDataTypeRaw {
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The binary document check will not correctly filter out binary documents that have xattrs. Since the xattr check at line 368 returns early for documents without xattrs, only documents WITH xattrs reach this check. For a binary document with xattrs, the DataType would be MemcachedDataTypeXattr (4), not MemcachedDataTypeRaw (0), so this equality check will fail and binary documents with xattrs will continue to be processed. The correct check should verify that the JSON flag is not set using a bitwise operation: event.DataType&base.MemcachedDataTypeJSON == 0.

Suggested change
// If this is a binary document, we can ignore.
if event.DataType == base.MemcachedDataTypeRaw {
// If this is not a JSON document (e.g. binary, with or without xattrs), we can ignore.
if event.DataType&base.MemcachedDataTypeJSON == 0 {

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.

2 participants