Skip to content
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

CBG-3157: Add opt-in send replacementRevs feature when encountering norev #6822

Merged
merged 17 commits into from
May 31, 2024

Conversation

bbrks
Copy link
Member

@bbrks bbrks commented May 13, 2024

CBG-3157

Add opt-in replacement revs feature.

  • In the event a requested revision is not sent, and a client has opted into this feature, we'll fetch the active revision of the document and send that instead.
  • Access checks for the replacement rev are performed by GetRev
  • Channel fitlers are checked to ensure the replacement rev is in the set of currently replicated channels

Integration Tests

@bbrks bbrks changed the title CBG-3157: Add sendReplacementRevs subChanges property CBG-3157: Add opt-in send replacementRevs feature when encountering norev May 13, 2024
@bbrks bbrks requested a review from adamcfraser May 14, 2024 15:11
db/blip_sync_context.go Show resolved Hide resolved
db/blip_sync_context.go Outdated Show resolved Hide resolved
@bbrks bbrks assigned bbrks and unassigned adamcfraser May 16, 2024
base/set.go Show resolved Hide resolved
@bbrks bbrks assigned adamcfraser and unassigned bbrks May 16, 2024
@bbrks bbrks requested a review from adamcfraser May 20, 2024 17:43
Copy link
Collaborator

@adamcfraser adamcfraser left a comment

Choose a reason for hiding this comment

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

Overall looks fine, a few questions on implementation details.

db/blip_collection_context.go Outdated Show resolved Hide resolved
@@ -579,7 +579,7 @@ func (bsc *BlipSyncContext) sendBLIPMessage(sender *blip.Sender, msg *blip.Messa
}

func (bsc *BlipSyncContext) sendNoRev(sender *blip.Sender, docID, revID string, collectionIdx *int, seq SequenceID, err error) error {
base.DebugfCtx(bsc.loggingCtx, base.KeySync, "Sending norev %q %s due to unavailable revision: %v", base.UD(docID), revID, err)
base.TracefCtx(bsc.loggingCtx, base.KeySync, "Sending norev %q %s due to unavailable revision: %v", base.UD(docID), revID, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we already log this information elsewhere, which is why we want to lower to Trace here? I thought norevs were generally unexpected and merited the debug logging.

Copy link
Member Author

@bbrks bbrks May 29, 2024

Choose a reason for hiding this comment

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

Good catch. I had intended to move the debug logging up a level so we could get more contextual information about why we're sending the norev.

Have covered all sendNoRev cases now with appropriate log messages.

db/blip_sync_context.go Outdated Show resolved Hide resolved
base.DebugfCtx(bsc.loggingCtx, base.KeySync, "Unavailable revision for %q %s - finding replacement: %v", base.UD(docID), revID, originalErr)

// try the active rev instead as a replacement
replacementRev, replacementRevErr := handleChangesResponseCollection.GetRev(bsc.loggingCtx, docID, "", true, nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's some inefficiency here, as we would have fetched the current version of the doc from the bucket when the revCacheLoader attempted to fetch the original (not found) rev.

Since the frequency of replacementRev is expected to be low I think we can live with this, but could consider filing a backlog enhancement to enhance revCacheLoader to have the ability to return activeRev during the initial fetch (or at least stick it in the rev cache).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure it's worth the complexity to cover this one case, and this is the only case we'd need that behaviour.

Are there stats we should add now (SendNoRevCount and SendReplacementRevCount?) to determine the frequency of this codepath to justify doing this work in future?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The stats do seem like they might be generally useful - both for understanding frequency and understanding what's going on in an environment. I'll leave it to you whether to include in this PR or file a followup ticket.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do as an immediate follow-up/PR (CBG-3960)

db/blip_sync_context.go Outdated Show resolved Hide resolved
@adamcfraser adamcfraser assigned bbrks and unassigned adamcfraser May 23, 2024
@bbrks bbrks assigned adamcfraser and unassigned bbrks May 29, 2024
@adamcfraser adamcfraser assigned bbrks and unassigned adamcfraser May 31, 2024
@bbrks bbrks merged commit 25a892e into main May 31, 2024
36 checks passed
@bbrks bbrks deleted the CBG-3157 branch May 31, 2024 09:50
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