New issue
Advanced search Search tips

Issue 847822 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Jun 2018
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

[USS] ClientTagBasedModelTypeProcessor is too strict for TYPED_URL

Project Member Reported by jkrcal@chromium.org, May 30 2018

Issue description

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

Can you please elaborate which cases would incur in performance penalty? Worst case, wouldn't the described issues be solved by exposing a new API in  ModelTypeChangeProcessor, something like IsEntityTracked(storage_key)?

I think relaxing the preconditions for UntrackEntityWithStorageKey() is fine and ignoring the calls for untracked entities.

I would however in principle dislike removing the DCHECK in CreateEntity() because it could hide a violation of the integrity invariant, i.e. corrupt state. Can you elaborate which situation leads to that?

In other words, a DCHECK is legit if the bridge violates the preconditions in ModelTypeChangeProcessor API. Is that the case? How exactly?

Comment 2 by jkrcal@chromium.org, Jun 12 2018

Status: WontFix (was: Assigned)
Okay, I relaxed UntrackEntityWithStorageKey to ignore unknown keys.

After reading the bridge a bit more, I see no performance penalty, in all changes, the full list of vitits gets read.

I close this bug as won't fix. The proper way is to fix the bridge.

Sign in to add a comment