gecko-dev/services/sync
Lina Cambridge 9320172d8f Bug 1567238 - Refactor the bookmarks mirror merge triggers to do less work. r=tcsc,markh
This commit reduces the number of database writes and table scans
needed to merge synced bookmarks.

* Remove `fetchNew{Local, Remote}Contents`. Fetching the tree already
  scans the table, so we can piggyback on it to fetch content info for
  deduping.
* Store completion ops in temp tables to only update changed parts of
  the local tree, and remove the `mergeStates` table and views.
* Replace the `itemsToMerge` view with an indexed `itemsToApply` temp
  table.
* Replace the `updateGuidsAndSyncFlags` trigger with a `changeGuidOps`
  table and a `changeGuids` trigger.
* Replace the `updateLocalItems` trigger with an `apply_remote_items`
  function to bulk upsert new and updated items.
* Replace the `structureToMerge` view with an
  `applyNewLocalStructureOps` table that holds parents and positions
  for moved items, and an `applyNewLocalStructure` trigger to update
  them.
* Remove tombstones for revived items, update change counters, and flag
  mirror items as merged directly in `update_local_items_in_places`,
  instead of indirecting through temp tables.
* Don't mark items flagged for reupload as merged, since we'll write
  them back to the mirror after upload.
* Use a scalar subquery instead of a join in the `localTags` view to
  look up the tags root ID.
* Replace `relatedIdsToReupload` with a `Store::prepare` method that
  flags all bookmarks with keyword-URL mismatches for reupload.
* Trigger frecency updates for origins once, not for every item.
* Remove two extra scans on `itemsAdded` and `itemsChanged` when
  recording observer notifications for changed keywords.
* Notify all `bookmark-added` listeners in a single batch.

This also fixes some edge cases:

* Update root positions correctly after deleting a non-syncable root
  or item.
* Keyword-URL mismatches may reupload more items than before, but now
  ensure that all bookmarks with the same URL have the same keyword.
* Only set items with deduped GUIDs to `SYNC_STATUS_NORMAL` after
  merging.
* Bump the last modified time for modified items only.

Differential Revision: https://phabricator.services.mozilla.com/D39889

--HG--
extra : moz-landing-system : lando
2019-08-06 23:48:03 +00:00
..
locales
modules Bug 1564131 - re-enable syncing of builtin themes. r=rpl 2019-07-18 01:25:50 +00:00
modules-testing Bug 1561435 - Format services/, a=automatic-formatting 2019-07-05 10:58:22 +02:00
tests Bug 1567238 - Refactor the bookmarks mirror merge triggers to do less work. r=tcsc,markh 2019-08-06 23:48:03 +00:00
tps/extensions/tps Bug 1561435 - Format services/, a=automatic-formatting 2019-07-05 10:58:22 +02:00
components.conf Bug 1524688: Part 15 - Convert Weave to static registration. r=markh 2019-01-29 20:44:18 -08:00
moz.build Bug 1524688: Part 15 - Convert Weave to static registration. r=markh 2019-01-29 20:44:18 -08:00
services-sync.js Bug 1548884 - Enable the synced bookmarks mirror on Nightly and Beta. r=tcsc 2019-05-06 20:40:20 +00:00
SyncComponents.manifest Bug 1524688: Part 15 - Convert Weave to static registration. r=markh 2019-01-29 20:44:18 -08:00
Weave.jsm Bug 1560455 - rename CodebasePrincipal to ContentPrincipal. r=ckerschb 2019-07-08 16:37:45 +00:00