Chromium Code Reviews
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 #
Messages
Total messages: 14 (9 generated)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||