We want to remove the JSON cache when the gloda database is nuked.
(followup to IRC discussion:) Yes, since SQLite uses schema_version internally and mozStorage/gloda uses user_version, I think the preference is the easiest way to handle associating a generated id for the gloda database so that dependent data like this JSON cache can know when to be blown away.
Created attachment 651835 [details] [diff] [review] Patch v1 This patch makes GlodaDatastore stash a UUID string in mailnews.database.global.datastore.id when the database is created, or if the GlodaDatastore is initted and no such pref value exists. The IM indexer now stores this datastoreID in the JSON cache, and checks for it when doing the initial folder sweep. If the datastoreID from the JSON cache does not match the one that is stored in preferences, this means that the cache is no longer valid, so it is ignored and eventually overwritten.
Comment on attachment 651835 [details] [diff] [review] Patch v1 The logic is good and I am super-happy about your detailed comments, but I would strongly prefer that Gloda, GlodaDatastore, or GlodaIndexer be the interface to the uuid rather than having index_im access the pref directly. Specifically I'm concerned that since it lives in a different folder and cargo culting is rife in our codebase and extensions that it's safest to have a more explicit interface.
Also, I think you could add a unit test for this logic pretty easily to test_corrupt_database.js. Specifically, set the preference to a made-up UUID at the start of the file before gloda gets bootstrapped. Then, near the end of the test, check that the exposed variable is now a new UUID and also directly probe that the preference has that same value.
Created attachment 651851 [details] [diff] [review] Patch v2 Thanks for the review, asuth! Ok, the datastoreID is now accessed via a getter in Gloda, and the IM indexer has been updated accordingly. I've also augmented the current test in test_corrupt_database.js to check on our UUID regeneration behaviour.
5 years ago
Comment on attachment 651851 [details] [diff] [review] Patch v2 Awesome, thanks! Bonus points for checking the new uuid length! (Redeemable in snacks at your local Mozilla Space.)
Comment on attachment 651851 [details] [diff] [review] Patch v2 Awesome - thanks for the reviews, asuth!
comm-aurora: https://hg.mozilla.org/releases/comm-aurora/rev/9ffbd5c6d544 comm-beta: https://hg.mozilla.org/releases/comm-beta/rev/24698041be04