DescriptionCheck 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.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=111033
Patch Set 1 #Patch Set 2 : Take action when corruption is detected #Patch Set 3 : Smaller patch, relies on other fixes #
Total comments: 3
Patch Set 4 : Respond to review comments #
Total comments: 1
Patch Set 5 : Remove unintentionally uploaded change #Patch Set 6 : Use hash_set<std::string> because custom traits are not standardized #Patch Set 7 : More win compile fixes #Patch Set 8 : Fix merge conflicts #
Messages
Total messages: 21 (0 generated)
|