Database move-and-recreate is flawed

RESOLVED FIXED

Status

()

RESOLVED FIXED
3 years ago
9 months ago

People

(Reporter: rnewman, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
When the database is found to be malformed, we close it, move it, and recreate in place.

(That means we need to do stuff like Bug 1226813, because we lose data.)

But we also lose any tables that were created in the DB, including the schema table itself; we call doCreate with the table that failed, but that's only correct if the first table fails!
(Reporter)

Comment 1

3 years ago
This is what it'll look like in the log:

[BrowserDB.swift:192] createOrUpdate > Moving browser.db-shm and browser.db-wal…
[SwiftData.swift:83] getSharedConnection() > >>> Creating shared SQLiteDBConnection for /private/var/mobile/Containers/Shared/AppGroup/6F866643-7E94-4F16-B6BE-83BBF503ADC1/profile.profile/browser.db on thread <NSThread: 0x15c67acb0>{number = 2, name = (null)}.
[SwiftData.swift:397] init(filename:flags:key:prevKey:) > Opening connection to /private/var/mobile/Containers/Shared/AppGroup/6F866643-7E94-4F16-B6BE-83BBF503ADC1/profile.profile/browser.db.
[SwiftData.swift:379] prepareCleartext() > Enabling WAL mode.
[BrowserDB.swift:58] createTable(_:table:) > Try create BROWSER version 11
[BrowserTable.swift:366] create > Creating 16 tables, views, and indices.
[SwiftData.swift:522] executeChange(_:withArgs:) > SQL error: SQL error or missing database no such table: tableList for SQL INSERT INTO tableList (name, version) VALUES (?,?).
(Reporter)

Comment 2

9 months ago
I believe this is now fixed.
Status: NEW → RESOLVED
Last Resolved: 9 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.