Closed Bug 1226813 Opened 11 years ago Closed 10 years ago

Reset sync when database corruption occurs

Categories

(Firefox for iOS :: Data Storage, defect)

All
iOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fxios 1.3+ ---

People

(Reporter: rnewman, Assigned: rnewman)

References

Details

Attachments

(1 external file)

Right now we attempt to re-create a corrupt or malformed DB. We don't tell Sync, though. So it just looks like your data has disappeared and won't come back. See Bug 1224692. When we replace a database, we should reset all sync engines that store data in that database -- passwords for logins.db, history + bookmarks (+ tabs?) for browser.db.
Richard where do we want to schedule this? Before 2.0?
Flags: needinfo?(rnewman)
Until we do this: a user who experiences DB corruption will likely never get their data back. They'll need to sign out of Sync then back in, but instead they'll probably uninstall the app in disgust. If we reliably fix DB corruption, this can wait for a month or so. If we don't have great leads (and I'll know more about that when I read TheLinks logs tomorrow), then this becomes more urgent. I would certainly take this in 1.3 (if someone is feeling sprightly) or 1.4. It's not difficult: when we replace browser.db, do: if !self.hasAccount { return } let deferred = walk(["bookmarks", "history", "tabs"], self.profile.syncManager.locallyResetCollection) when we replace logins.db: if !self.hasAccount { return } let deferred = self.profile.syncManager.locallyResetCollection("passwords")
Flags: needinfo?(rnewman)
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
Tests on the PR. Manually tested. This is the last thing I want to get into 1.3.
Whiteboard: [needsuplift]
Comment on attachment 8693889 [details] [review] Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1324 Looks good to me
Attachment #8693889 - Flags: review?(sleroux) → review+
master: f7e8e11
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
v1.x: fa72549
Whiteboard: [needsuplift]
Target Milestone: --- → 1.3
Attachment #8693889 - Flags: review?(bnicholson)
Richard, I've noticed that "database downgrade causes Sync to partially fail". I can create a new bug if it is not related. But, here's what happens: 1. On one git branch (let's say upgraded_db_branch), I'm testing a new database version upgrade with changes for one table. I'm also logged into Sync. 2. On another branch (current_db_branch), I'm still using the current database version for an unrelated bug. 3. When I switch from upgraded_db_branch to current_db_branch, and build and run, I notice that I have only a very small subset of synced topsites and highlights (I assume only the updates since the most recent sync appear). The bookmarks are empty. Even the history is a small subset. However, the sync status shows that the sync happened after the branch switch, build and run. On a subsequent auto sync, the highlights list grows, but the bookmarks are still empty. It doesn't help matters if I attempt to manually sync. As per this, https://github.com/mozilla-mobile/firefox-ios/blob/master/Storage/SQL/BrowserTable.swift#L613, I assume that the browser database downgrade is not an issue. But, the sync is probably not being told of the downgrade?
Flags: needinfo?(rnewman)
It's impossible for a downgrade to occur in the wild -- not only do we not ship a release that uses an earlier DB version, but users can't even manually install an APK as they can on Android. As you've noticed, there's code in the tree that throws away and recreates a table on downgrade, and that will certainly screw up Sync! The table mechanism that does so is pretty dumb: it acts at the table level. (And if we upgrade the "schema schema" for table tracking, it's totally screwed!) Obviously that's wrong if there are interdependencies. It would probably be incorrect to try to add a Sync-related fix at that point: if we really do want to handle downgrades, we should do so by throwing away the entire DB, or the developer should implement a downgrade if they feel very motivated. I would be pretty leery of adding code to the tree that could apply *incorrectly* and catastrophically, when that code should never be necessary in the wild.
Flags: needinfo?(rnewman)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: