DescriptionMerge 111033 - Check node references during sync DB init
This commit adds a check to verify that the NEXT_ID, PREV_ID and
PARENT_ID fields of nodes in the database point to the IDs of other
existing nodes. The syncable::Database code assumes that this invariant
always holds and seems to do a good job of maintaining it. This change
ensures that the invariant holds at the time the data is loaded from
disk.
There exist some corrupt databases that cause the directory to behave
unpredictably, since the code assumes the databsae is correct when it is
read from disk. We can't do anything to fix those databases now that
they've been written, but we can detect the corruption and recreate the
affected databases.
This check is implemented using a set of hash maps, so the cost of the
check should scale well with the number of nodes (it's O(n)). The
per-node cost of this check also seems cheap compared to the disc
access. In release mode, loading 5000 nodes from a (probably in-cache)
sqlite database took 53ms, while the check took 9 ms.
BUG=101048
TEST=Manual. Corrupted the database with external sqlite tool, verified
that the database was deleted and re-created next time Chrome was loaded.
Review URL: http://codereview.chromium.org/8475017
TBR=rlarocque@chromium.org
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=111791
Patch Set 1 #
Messages
Total messages: 1 (0 generated)
|