-
Notifications
You must be signed in to change notification settings - Fork 141
CBG-5170 change listener: don't process docs without xattr #8064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -364,25 +364,25 @@ func (c *changeCache) DocChanged(event sgbucket.FeedEvent, docType DocumentType) | |||||||||
|
|
||||||||||
| ctx = collection.AddCollectionContext(ctx) | ||||||||||
|
|
||||||||||
| // If this is a delete and there are no xattrs (no existing SG revision), we can ignore | ||||||||||
| if event.Opcode == sgbucket.FeedOpDeletion && len(docJSON) == 0 { | ||||||||||
| base.DebugfCtx(ctx, base.KeyCache, "Ignoring delete mutation for %s - no existing Sync Gateway metadata.", base.UD(docID)) | ||||||||||
| // If the document has no xattrs, it can not have a _sync xattr | ||||||||||
| if event.DataType&base.MemcachedDataTypeXattr == 0 { | ||||||||||
| return | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // If this is a binary document, we can ignore. | ||||||||||
| if event.DataType == base.MemcachedDataTypeRaw { | ||||||||||
| return | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // If this is a binary document (and not one of the above types), we can ignore. Currently only performing this check when xattrs | ||||||||||
| // are enabled, because walrus doesn't support DataType on feed. | ||||||||||
| if collection.UseXattrs() && event.DataType == base.MemcachedDataTypeRaw { | ||||||||||
| // If this is a delete and there are no xattrs (no existing SG revision), we can ignore | ||||||||||
| if event.Opcode == sgbucket.FeedOpDeletion && len(docJSON) == 0 { | ||||||||||
| base.DebugfCtx(ctx, base.KeyCache, "Ignoring delete mutation for %s - no existing Sync Gateway metadata.", base.UD(docID)) | ||||||||||
| return | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // First unmarshal the doc (just its metadata, to save time/memory): | ||||||||||
| doc, syncData, err := UnmarshalDocumentSyncDataFromFeed(docJSON, event.DataType, collection.UserXattrKey(), false) | ||||||||||
| if err != nil { | ||||||||||
| // Avoid log noise related to failed unmarshaling of binary documents. | ||||||||||
| if event.DataType != base.MemcachedDataTypeRaw { | ||||||||||
| 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) | ||||||||||
| } | ||||||||||
| if errors.Is(err, sgbucket.ErrEmptyMetadata) { | ||||||||||
| base.WarnfCtx(ctx, "Unexpected empty metadata when processing feed event. docid: %s opcode: %v datatype:%v", base.UD(event.Key), event.Opcode, event.DataType) | ||||||||||
|
||||||||||
| base.WarnfCtx(ctx, "Unexpected empty metadata when processing feed event. docid: %s opcode: %v datatype:%v", base.UD(event.Key), event.Opcode, event.DataType) | |
| base.WarnfCtx(ctx, "Unexpected empty metadata when processing feed event. docid: %s opcode: %v datatype:%v", base.UD(event.Key), event.Opcode, event.DataType) | |
| } else { | |
| base.DebugfCtx(ctx, base.KeyCache, "Error unmarshalling sync data from feed for %s (opcode:%v datatype:%v): %v", base.UD(event.Key), event.Opcode, event.DataType, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new early return for documents without xattrs (line 368-370), this warning about empty metadata may no longer be reachable or relevant. Consider adding a comment explaining when this condition could still occur, or verify if this error handling is still necessary given the earlier xattr check.