Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Issue 2690913005: [Sync] Update EntityData on all codepaths from model type sync bridge (Closed)

Created:
3 years, 10 months ago by pavely
Modified:
3 years, 10 months ago
Reviewers:
skym
CC:
chromium-reviews, sync-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Sync] Update EntityData on all codepaths from model type sync bridge When passing nEntityData to change processor, sync bridge usually only populates few required fields: specifics and non_unique_name. It also provides storage key and, indirectly, client tag. It is a responsibility of change processor to populate remaining fields (id, creation time, modification time) before passing EntityData to worker. values for these fields come from metadata. There are a few scenarios how change processor receives EntityData to be committed: 1. Local change: bridge creates new entry or updates existing one 2. Conflict resolution where bridge overrides resulting entity with locally generated specifics. 3. Committing pending changes after restart: change processor detects entities that need to be committed and requests EntityData from bridge. 4. Local reencryption 5. Reencryption after receiving remote update with outdated key. The issue is that in a few scenarios above id is not copied from metadata to EntityData. As a result when committing pending changes change processor sets valid base_version in CommitRequestData but keeps id empty causing DCHECK in ModelTypeWorker. The solution is to treat metadata as the source of truth and to always populate EntityData fields from metadata. Code path looks approximately like this: - Update metadata if needed (cases 1 and 2). Implemented in ProcessorEntityTracker::MakeLocalChange) - Copy fields from metadata to EntityData (cases 1-4). Implemented in ProcessorEntityTracker::SetCommitData Case 5 is special. EntityData doesn't come from bridge, but instead from sync server and therefore doesn't need to be adjusted. This change is not final. There is one more case where metadata can be updated after EntityData is wrapped into EntityDataPtr and made immutable: - Local client creates new entity and enqueues it for commit. (entity is immutable) - Update from server comes with entity with the same client tag hash and valid id. - Conflict resolution logic kicks in and, if it is resolved with "Local wins" resolution, then original EntityData (with still empty id) should be committed. I'll make a separate change for this scenario as it is more involved. The chances of hitting it are much smaller compared to currently broken "committing pending changes" scenario, therefore I think it is important to land this partial fix and merge it to M57. I've fixed how assigning id to new entity is handled in MockModelTypeWorker::SuccessfulCommitResponse. I've added checks that validate id/version combination into ProcessorEntityTracker and MockModelTypeWorker. They verify correctness of this change on scenarios from SharedModelTypeProcessorTest. BUG=672100 R=skym@chromium.org Review-Url: https://codereview.chromium.org/2690913005 Cr-Commit-Position: refs/heads/master@{#450227} Committed: https://chromium.googlesource.com/chromium/src/+/4d9357af0df028dab696fe7c4e7cce2815da01ef

Patch Set 1 #

Total comments: 6

Patch Set 2 : Address comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+64 lines, -43 lines) Patch
M components/sync/model_impl/processor_entity_tracker.h View 1 chunk +4 lines, -3 lines 0 comments Download
M components/sync/model_impl/processor_entity_tracker.cc View 1 3 chunks +23 lines, -13 lines 0 comments Download
M components/sync/model_impl/shared_model_type_processor.cc View 2 chunks +9 lines, -12 lines 0 comments Download
M components/sync/model_impl/shared_model_type_processor_unittest.cc View 3 chunks +20 lines, -12 lines 0 comments Download
M components/sync/test/engine/mock_model_type_worker.cc View 2 chunks +8 lines, -3 lines 0 comments Download

Messages

Total messages: 14 (9 generated)
pavely
3 years, 10 months ago (2017-02-13 22:58:23 UTC) #3
skym
Amazing CL description Pavel. Feel free to ignore any/all changes, especially if you plan to ...
3 years, 10 months ago (2017-02-14 00:33:41 UTC) #4
pavely
https://codereview.chromium.org/2690913005/diff/1/components/sync/model_impl/processor_entity_tracker.cc File components/sync/model_impl/processor_entity_tracker.cc (right): https://codereview.chromium.org/2690913005/diff/1/components/sync/model_impl/processor_entity_tracker.cc#newcode68 components/sync/model_impl/processor_entity_tracker.cc:68: if (data->creation_time.is_null()) On 2017/02/14 00:33:40, skym wrote: > What ...
3 years, 10 months ago (2017-02-14 02:09:42 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2690913005/20001
3 years, 10 months ago (2017-02-14 02:10:13 UTC) #11
commit-bot: I haz the power
3 years, 10 months ago (2017-02-14 03:48:54 UTC) #14
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://chromium.googlesource.com/chromium/src/+/4d9357af0df028dab696fe7c4e7c...

Powered by Google App Engine
This is Rietveld 408576698