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

Feature/issue 3738 norev #3763

Merged
merged 11 commits into from
Sep 26, 2018
Merged

Feature/issue 3738 norev #3763

merged 11 commits into from
Sep 26, 2018

Conversation

tleyden
Copy link
Contributor

@tleyden tleyden commented Sep 25, 2018

Fixes #3738

@bbrks
Copy link
Member

bbrks commented Sep 25, 2018

Hey @tleyden , if you rebase this on the latest release/2.1.1 you should get a working branch build (although slow due to current network issues).


func (bh *blipHandler) sendNoRev(err error, sender *blip.Sender, seq db.SequenceID, docID string, revID string, knownRevs map[string]bool, maxHistory int) {

bh.Logf(base.LevelDebug, base.KeySync, "Sending norev %q %s based on %d known. User:%s", base.UD(docID), revID, len(knownRevs), base.UD(bh.effectiveUsername))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think any logging for the norev message should include the error details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
}

func (bh *blipHandler) sendNoRev(err error, sender *blip.Sender, seq db.SequenceID, docID string, revID string, knownRevs map[string]bool, maxHistory int) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

knownRevs and maxHistory aren't relevant for sendNoRev, can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

outrq.Properties["sequence"] = string(seqJSON)
if marshalErr == nil {
outrq.Properties["sequence"] = string(seqJSON)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at the spec, sequence is generally optional in a rev message, other than the case where a changes message hasn't been sent. I don't think we have that scenario for rev messages sent by Sync Gateway. If we can omit sequence altogether, we should file a ticket for that change for Iridium.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What problem gets solved by omitting the sequence whenever possible? (performance?)

It seems potentially useful from a debugging / diagnostics point of view, but the number of cases where it's useful might be narrow: for example if there was a bug that caused peer sync gateways to send back different versions of a particular revision of a doc, it would be useful to see what sequence they thought the revisions were based off of. (I realize this might not be a realistic scenario, I'm just saying that there might be scenarios we can't think of that could be useful to have more info)

Since a norev message is always solicited, I will update the spec to say (optional), without the unsolicited caveat. Along those lines, it could always be omitted from norev messages, but I wanted to understand the motivation.

If we can omit sequence altogether, we should file a ticket for that change for Iridium.

I'll file that and we can move the discussion over there. I think for this PR we could just keep things as-is, and as part of that Iridium ticket go back and change the behavior for both rev and norev messages.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Motivation is to reduce CPU cost on SG (marshalling sequence) and transport cost to clients. Agree that this doesn't need to be changed for this PR.

If there are actually low-level troubleshooting benefits, we should address those via logging. (although I don't know of any cases where id/rev could be associated with different sequences).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking closer, the sequence that we're sending in the rev message is always just the sequence we previously sent in the changes message - we're not attempting to recalculate it from the document's current metadata. Given that, I think there's even less value in sending it back to the client on the rev message. I'm not sure why the changes response from CBL is specifying sequence, in fact. Should be reviewed w/ #3764

@tleyden
Copy link
Contributor Author

tleyden commented Sep 26, 2018

The jenkins job finished without issues, so I'm going to go ahead and merge

@tleyden tleyden merged commit 0d62906 into release/2.1.1 Sep 26, 2018
@tleyden tleyden deleted the feature/issue_3738_norev branch September 26, 2018 01:52
adamcfraser pushed a commit that referenced this pull request Oct 19, 2018
* Repro attempt for SG #3738

* /_flush_rev_cache endpoint for easy manual testing

* TODOs on fix

* Clean up test

* First pass at implmenting norev

* Update test helper to deal with norev messages

* Translate error to status code

* Avoid panic if there is a marshal err for the sequence

* Revert "/_flush_rev_cache endpoint for easy manual testing"

This reverts commit 9e54548.

* Update test comment

* PR feedback
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