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

Use sync no merge #3798

Closed
wants to merge 3 commits into from
Closed

Use sync no merge #3798

wants to merge 3 commits into from

Conversation

@AlexeyBarabash
Copy link
Contributor

AlexeyBarabash commented Oct 28, 2019

Submitter Checklist:

Fixes brave/brave-browser#6636

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.
@AlexeyBarabash AlexeyBarabash requested review from bridiver, bsclifton and darkdh Oct 28, 2019
@AlexeyBarabash AlexeyBarabash self-assigned this Oct 28, 2019
@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Oct 28, 2019

This is marked as draft because I found at least one STR which does not work well.

  1. Create profile A with bookmarks A1.com, A2.com

  2. Create profile B with bookmarks B1.com, B2.com

  3. Enable sync on device A

  4. Connect device B to the sync chain with code-phrase

  5. An device A create a folder FolderA and bookmark a.com

  6. Wait while FolderA and a.com appear on device B

  7. On device B move bookmark a.com into FolderA

  8. On device A this change will never be reflected, but expected

For now, from what I have seen, deviceB does not sends UPDATE + new parentObjectId record.

@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Oct 29, 2019

STR from above work fine on master branch.
I cannot reproduce STR on master branch of brave-core

@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Nov 27, 2019

Here is what happens inside when the issue above happens.

There are two important points.

I. When bookmark is applied to model, it is placed to the correct position in BookmarkChangeProcessor::ApplyChangesFromSyncModel . Also here after we moved bookmark, we have to update chromium syncer node for the new positon to make bookmark node in bookmark model match bookmark sync node for the position data. Here is the stack illustrating this:

[17850:17850:1122/173144.212771:ERROR:model_neutral_mutable_entry.cc(173)] [BraveSync] PutIsUnsynced INSERT unsynced GetNonUniqueName()=AA.com
#3 0x5626be1a90c4 syncer::syncable::ModelNeutralMutableEntry::PutIsUnsynced()
#4 0x5626be1df45e syncer::syncable::MarkForSyncing()
#5 0x5626bf827299 syncer::WriteNode::MarkForSyncing()
#6 0x5626bf829bfa syncer::WriteNode::SetPosition()
#7 0x5626bf9d36bc sync_bookmarks::BookmarkChangeProcessor::PlaceSyncNode()
#8 0x5626bf9d342b sync_bookmarks::BookmarkChangeProcessor::MoveSyncNode()
#9 0x5626bf9d81d2 sync_bookmarks::BookmarkChangeProcessor::ApplyChangesFromSyncModel()
#10 0x5626be2a883c syncer::SyncBackendRegistrar::OnChangesApplied()

This causes bookmark resending on next sync send cycle for each moved bookmark which just had been applied from the cloud. Chromium does not have such behaviour because Chromium does not need to update bookmark sync node after moving bookmark node in model.

II. The actual situation for the STR above.

The problem: deviceB does not send record AA.com with a new parentObjectId.

Steps from deviceB:

  1. get-existing-objects AA.com "parentFolderObjectId":{} - OK
  2. resolve-sync-records ...
  3. resolved-sync-records AA.com "parentFolderObjectId":{} - OK
  4. AA.com is applied to model
  5. AA.com is marked as UNSYNCED as in pt.I above:
[17850:17850:1122/173144.212771:ERROR:model_neutral_mutable_entry.cc(173)] [BraveSync] PutIsUnsynced INSERT unsynced GetNonUniqueName()=AA.com
#3 0x5626be1a90c4 syncer::syncable::ModelNeutralMutableEntry::PutIsUnsynced()
#4 0x5626be1df45e syncer::syncable::MarkForSyncing()
#5 0x5626bf827299 syncer::WriteNode::MarkForSyncing()
#6 0x5626bf829bfa syncer::WriteNode::SetPosition()
#7 0x5626bf9d36bc sync_bookmarks::BookmarkChangeProcessor::PlaceSyncNode()
#8 0x5626bf9d342b sync_bookmarks::BookmarkChangeProcessor::MoveSyncNode()
#9 0x5626bf9d81d2 sync_bookmarks::BookmarkChangeProcessor::ApplyChangesFromSyncModel()
#10 0x5626be2a883c syncer::SyncBackendRegistrar::OnChangesApplied()

from this point the mess begins

  1. preparing sync entity to be sent into Brave cloud
[BraveSync] ConvertCommitsToBraveRecords bm_specifics.title()=AA.com
  1. send-sync-records AA.com "parentFolderObjectId":{}

  2. AA.com is marked synced, because it passed ProcessCommitResponse

[17850:18355:1122/173151.829373:ERROR:model_neutral_mutable_entry.cc(181)] [BraveSync] PutIsUnsynced ERASE unsynced GetNonUniqueName()=AA.com
#3 0x5626be1a9371 syncer::syncable::ModelNeutralMutableEntry::PutIsUnsynced()
#4 0x5626be23681e syncer::commit_util::(anonymous namespace)::ProcessSuccessfulCommitResponse()
#5 0x5626be236386 syncer::commit_util::ProcessSingleCommitResponse()
#6 0x5626be234376 syncer::DirectoryCommitContribution::ProcessCommitResponse()
#7 0x5626be27bffc syncer::Commit::PostAndProcessResponse()
#8 0x5626be261146 syncer::Syncer::BuildAndPostCommits()
#9 0x5626be2608da syncer::Syncer::NormalSyncShare()
#10 0x5626be24ea42 syncer::SyncSchedulerImpl::DoNudgeSyncCycleJob()
  1. We are moving bookmark AA.com into folderA and bookmark sync node is marked as UNSYNCED
[17850:17850:1122/173217.842695:ERROR:model_neutral_mutable_entry.cc(173)] [BraveSync] PutIsUnsynced INSERT unsynced GetNonUniqueName()=AA.com
#3 0x5626be1a90c4 syncer::syncable::ModelNeutralMutableEntry::PutIsUnsynced()
#4 0x5626be1df45e syncer::syncable::MarkForSyncing()
#5 0x5626be23bb28 syncer::syncable::UpdateEntryWithEncryption()
#6 0x5626bf827c62 syncer::WriteNode::SetEntitySpecifics()
#7 0x5626bf827df7 syncer::WriteNode::SetBookmarkSpecifics()
#8 0x5626bf9d4929 sync_bookmarks::BookmarkChangeProcessor::SetSyncNodeMetaInfo()
#9 0x5626bf9d67c9 sync_bookmarks::BookmarkChangeProcessor::BookmarkNodeMoved()
#10 0x5626be0a7084 bookmarks::BookmarkModel::Move()
#11 0x5626c017a474 chrome::DropBookmarks()
  1. Happens next scheduled get-existing-objects and we get AA.com from pt.7
    get-existing-objects AA.com "parentFolderObjectId":{}

  2. resolve-sync-records we send pair [{server_record, local_record}] here
    so we send
    resolve-sync-records [{AA.com, "parentFolderObjectId":{}}, {AA.com, "parentFolderObjectId":{NEW_PARENT}}]

  3. sync lib does resolve to {AA.com, "parentFolderObjectId":{NEW_PARENT}} , because timestampt is later

  4. The main point ConflictResolver marks bookmark sync entity of AA.com which has a NEW_PARENT as synced, so it is excluded from the next sending to Brave AWS:

[17850:18355:1122/173221.990694:ERROR:get_updates_processor.cc(60)] [BraveSync] AddBookmarkSpecifics cloud sync title=AA.com
[17850:17850:1122/173222.001605:ERROR:model_neutral_mutable_entry.cc(181)] [BraveSync] PutIsUnsynced ERASE unsynced GetNonUniqueName()=AA.com
#3 0x5626be1a9371 syncer::syncable::ModelNeutralMutableEntry::PutIsUnsynced()
#4 0x5626be22bf85 syncer::conflict_util::IgnoreLocalChanges()
#5 0x5626be22ae0f syncer::ConflictResolver::ProcessSimpleConflict()
#6 0x5626be22b598 syncer::ConflictResolver::ResolveConflicts()
#7 0x5626be228faa syncer::DirectoryUpdateHandler::ApplyUpdatesImpl()

This happened because incoming update is equal to pending changes.

@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Nov 27, 2019

I am going to introduce into brave/sync#353 the 3rd state like resolve to none if remote record is equal to local record to see , will it help for STR above. Seems it should.

@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Nov 29, 2019

Attempt to intruduce resolve equal records to [] didn't help because we have to
resolve-sync-records [{AA.com, "parentFolderObjectId":{}}, {AA.com, "parentFolderObjectId":{NEW_PARENT}}]
which are different and all goes the same way.

The solution could be to avoid mark chromium sync nodes as UNSYNCED after moving bookmark.
We do move in BookmarkChangeProcessor::ApplyChangesFromSyncModel and this will be removed soon. Maybe the issue will gone after switching to USSBookmarks as discussed with @darkdh .

@AlexeyBarabash
Copy link
Contributor Author

AlexeyBarabash commented Mar 13, 2020

Closing as moving to sync v2

@bsclifton bsclifton deleted the use_sync_no_merge branch May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

1 participant
You can’t perform that action at this time.