Closed Bug 1305180 Opened 9 years ago Closed 9 years ago

TestBrowserDB.testMovesDB test is broken.

Categories

(Firefox for iOS :: Build & Test, defect, P2)

Other
iOS
defect

Tracking

()

RESOLVED FIXED
Tracking Status
fxios 6.0+ ---
fxios-v5.3 --- affected
fxios-v6.0 --- fixed

People

(Reporter: farhan, Assigned: sleroux)

Details

(Whiteboard: [mobileAS])

Attachments

(1 file)

Recently the test testMovesDB has broke. This might be related to the recent additions to the browser table related to Recommendations or the hotfix that went in for the top crasher we have. Simply run the test to reproduce the issue. It crashes with fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “foo.db-shm” couldn’t be opened because there is no such file." This test is currently broken on master 9f724fbe8ee46d5ba812fbbfc7235f10df370fb6
Steph, If you could have a look at this. That would be awesome. We have an assert that is suppose to check if the file exists and that passes. But somehow when it tries to open the same file it crashes. Someone on irc was having this issue earlier and I tried it myself on master.
Flags: needinfo?(sleroux)
Assignee: nobody → sleroux
Flags: needinfo?(sleroux)
Looks like this was caused by the patch we landed to close the database when the app goes into the background [1] which was causing our iOS 10 springboard crash. What seems to be happening is that when try to create the failing table in the test case [2], the database files are never moved after the database is closed because we now completely ignore [3] any connections made after we call `forceClose` on the DB [4]. :rnewman, would it make sense to move the .bak moving file logic before we call forceClose? [1] https://github.com/mozilla-mobile/firefox-ios/commit/c3d742b80fe6af361cf9543271b9978c2d66730f [2] https://github.com/mozilla-mobile/firefox-ios/blob/master/StorageTests/TestBrowserDB.swift#L86 [3] https://github.com/mozilla-mobile/firefox-ios/blob/master/Storage/ThirdParty/SwiftData.swift#L87 [4] https://github.com/mozilla-mobile/firefox-ios/blob/master/Storage/SQL/BrowserDB.swift#L186
Flags: needinfo?(rnewman)
If I'm understanding you correctly, this might be a real bug. The forceClose call in BrowserDB is trying to forcibly close the database handle, so that it's free to move all of the old stuff out of the way and try again. Later on, we call db.transaction to open a connection to a new database in the same place, and create all the tables[1]. This relies on the underlying DB quietly reopening or recreating the DB. Now that forceClose means we never open a connection again, this logic is broken: we'll force close, move the files out of the way, and then we won't be able to 'reopen' the database again! In the test, the subsequent recreate will fail… which the test already expects, but for the wrong reason. My suggestion is that we add `self.reopenIfClosed()` at line 227, so that we get back on the old tracks. [1] <https://github.com/mozilla-mobile/firefox-ios/blob/master/Storage/SQL/BrowserDB.swift#L228>
Flags: needinfo?(rnewman)
Comment on attachment 8796616 [details] [review] Link to Github pull-request: https://github.com/mozilla-mobile/firefox-ios/pull/2133 Thanks for looking at this. Is this something that we might want to uplift to 5.x?
Attachment #8796616 - Flags: review?(fpatel) → review+
> Thanks for looking at this. Is this something that we might want to uplift to 5.x? Yup definitely.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: