Skip to content

Commit ee73d54

Browse files
authored
Revert "[4.0.4 backport] CBG-5197 change listener: don't process docs… (#8130)
1 parent 8de4d25 commit ee73d54

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

db/change_cache.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,23 +363,27 @@ func (c *changeCache) DocChanged(event sgbucket.FeedEvent, docType DocumentType)
363363

364364
ctx = collection.AddCollectionContext(ctx)
365365

366-
// If the document has no xattrs, it can not have a _sync xattr
367-
if event.DataType&base.MemcachedDataTypeXattr == 0 {
366+
// If this is a delete and there are no xattrs (no existing SG revision), we can ignore
367+
if event.Opcode == sgbucket.FeedOpDeletion && len(docJSON) == 0 {
368+
base.DebugfCtx(ctx, base.KeyCache, "Ignoring delete mutation for %s - no existing Sync Gateway metadata.", base.UD(docID))
368369
return
369370
}
370371

371-
// If this is a binary document, we can ignore.
372-
if event.DataType == base.MemcachedDataTypeRaw {
372+
// If this is a binary document (and not one of the above types), we can ignore. Currently only performing this check when xattrs
373+
// are enabled, because walrus doesn't support DataType on feed.
374+
if collection.UseXattrs() && event.DataType == base.MemcachedDataTypeRaw {
373375
return
374376
}
375377

376378
// First unmarshal the doc (just its metadata, to save time/memory):
377379
doc, syncData, err := UnmarshalDocumentSyncDataFromFeed(docJSON, event.DataType, collection.UserXattrKey(), false)
378380
if err != nil {
381+
// Avoid log noise related to failed unmarshaling of binary documents.
382+
if event.DataType != base.MemcachedDataTypeRaw {
383+
base.DebugfCtx(ctx, base.KeyCache, "Unable to unmarshal sync metadata for feed document %q. Will not be included in channel cache. Error: %v", base.UD(docID), err)
384+
}
379385
if errors.Is(err, sgbucket.ErrEmptyMetadata) {
380386
base.WarnfCtx(ctx, "Unexpected empty metadata when processing feed event. docid: %s opcode: %v datatype:%v", base.UD(event.Key), event.Opcode, event.DataType)
381-
} else {
382-
base.DebugfCtx(ctx, base.KeyCache, "Unable to unmarshal sync metadata for feed document %q. Will not be included in channel cache. Error: %v", base.UD(docID), err)
383387
}
384388
return
385389
}

0 commit comments

Comments
 (0)