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

Issue 1136953013: Sync: Change Local IDs to GUID based to avoid ID collision (Closed)

Created:
5 years, 7 months ago by stanisc
Modified:
5 years, 7 months ago
Reviewers:
maniscalco
CC:
chromium-reviews, tim+watch_chromium.org, zea+watch_chromium.org, maxbogue+watch_chromium.org, pvalenzuela+watch_chromium.org, plaree+watch_chromium.org, maniscalco+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Sync: Change Local IDs to GUID based to avoid ID collision This changes implementation of Directory::NextId() to no longer depend on "next_id" counter stored in Sync DB. Even though there was a special precaution to avoid potential collision of local IDs by fast forwarding next_id by a large number on every save there are still a couple scenarios leading the the collision between a local ID generated on a client and originator_client_item_id coming from the server (which is basically a local ID of an item previously committed to the server. The new implementation of Directory::NextId() is based on base::GenerateGUID. The following changes accompany the transition to the new ID format: 1) The next_id field is no longer needed in Directory::PersistedKernelInfo 2) The code that persists next_id is no longer needed. 3) Forcing the directory to save by marking it with KERNEL_SHARE_INFO_DIRTY flag right after loading it is no longer necessary. That was done primarily to increment next_id by a large value as a way to attempt this problem. 4) Fixing #3 revealed a bug in Directory::IncrementTransactionVersion that doesn't mark the directory with KERNEL_SHARE_INFO_DIRTY when incrementing a datatype's transaction version. That caused a number of bookmark tests to fail due to the transaction version check. Fixed it. 5) Changing local IDs to GUIDs had a subtle effect on some tests. For the types that don't support ordering, sorting of entries in ParentChildIndex defaults to ID comparison. Since generation of local IDs base on next_id followed a predictable pattern, some tests relied on order of items returned by ParentChildIndex. Switching to GUIDs disrupted the expected order (of entries that are unordered in their nature). To preserve the existing ordering pattern for unordered entries, I changed ParentChildIndex to default to META_HANDLE comparison. 6) Another test that failed due to the GUID transition was SyncableDirectoryTest.BookmarkTagTest. The test relied on a predefined, repeatable local ID which was no longer the case with the GUID generation. I found the test to be redundant. There is another tests that verifies the same functionality - unique bookmark tag generation algorithm. For now the change leaves next_id in the database even though the field is no longer used. I should probably file another bug to track its removal. BUG=362467 Committed: https://crrev.com/51f97d05f1e865f6dee84f568ee44cb0640a08fc Cr-Commit-Position: refs/heads/master@{#329946}

Patch Set 1 #

Patch Set 2 : Test #

Patch Set 3 : Fixed test failures #

Patch Set 4 : Fixed setting KERNEL_SHARE_INFO_DIRTY when incrementing transaction version #

Total comments: 6

Patch Set 5 : Changed comments for Directory::NextId() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -103 lines) Patch
M sync/syncable/directory.h View 1 2 3 4 2 chunks +1 line, -3 lines 0 comments Download
M sync/syncable/directory.cc View 1 2 3 4 6 chunks +7 lines, -23 lines 0 comments Download
M sync/syncable/directory_backing_store.cc View 2 chunks +6 lines, -10 lines 0 comments Download
M sync/syncable/directory_backing_store_unittest.cc View 1 1 chunk +0 lines, -20 lines 0 comments Download
M sync/syncable/directory_unittest.cc View 1 2 1 chunk +0 lines, -30 lines 0 comments Download
M sync/syncable/in_memory_directory_backing_store.h View 1 2 1 chunk +0 lines, -6 lines 0 comments Download
M sync/syncable/in_memory_directory_backing_store.cc View 1 2 2 chunks +1 line, -10 lines 0 comments Download
M sync/syncable/parent_child_index.cc View 1 2 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 9 (3 generated)
stanisc
PTAL
5 years, 7 months ago (2015-05-14 01:54:59 UTC) #2
maniscalco
Very nice. LGTM, just a few comments. I'll follow up with you OOB about an ...
5 years, 7 months ago (2015-05-14 15:54:21 UTC) #3
stanisc
https://codereview.chromium.org/1136953013/diff/60001/sync/syncable/directory.cc File sync/syncable/directory.cc (right): https://codereview.chromium.org/1136953013/diff/60001/sync/syncable/directory.cc#newcode1334 sync/syncable/directory.cc:1334: // Always returns a client ID that is the ...
5 years, 7 months ago (2015-05-14 21:21:56 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1136953013/80001
5 years, 7 months ago (2015-05-14 22:09:46 UTC) #7
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years, 7 months ago (2015-05-14 22:16:16 UTC) #8
commit-bot: I haz the power
5 years, 7 months ago (2015-05-14 22:17:06 UTC) #9
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/51f97d05f1e865f6dee84f568ee44cb0640a08fc
Cr-Commit-Position: refs/heads/master@{#329946}

Powered by Google App Engine
This is Rietveld 408576698