When dealing with crbug.com/827111, I found many inconsistencies between the data and metadata in the history DB for TYPED_URLs and also many potential causes in the code, e.g.:
- new URLs may be ignored due to many early returns in TypedURLSyncBridge::OnURLVisited() and TypedURLSyncBridge::FixupURLAndGetVisits()
- the DB calls do not happen very atomically as witnessed by this extra-ordinary hack
https://cs.chromium.org/chromium/src/components/history/core/browser/typed_url_sync_bridge.cc?l=1098
- expired URLs did not get their metadata deleted at all until recently.
This does not work fine with various DCHECKs in the processor. On some places such as in the Delete function there are no DCHECKs (again, heavily exploited by the TypedUrlSyncBridge because it has no clue whether an entity is tracked by sync when it calls Delete() from OnURLsDeleted()).
It would be nice to fix the bridge but in some cases we would pay a performance penalty (more reading from the DB as the bridge keeps no in-memory copy of neither the data nor the metadata).
I propose to relax the pre-conditions and replace such DCHECKs with DLOGs + metrics keyed by model type + early returns.
I propose to start with
- CreateEntity (now DCHECKing that no other entity with the same tag hash exists)
- UntrackEntityWithStorageKey (now DCHECKing/crashing when such an entity is not tracked).
Comment 1 by mastiz@chromium.org
, May 30 2018