places.sqlite Database Troubleshooting

This article describes troubleshooting actions to deal with a broken places.sqlite database.

How to (try to) recover from a corrupt places.sqlite

Sometimes after a Firefox/Aurora/Nightly upgrade, history disappears, but bookmarks are at their place. In the profile folder a places.sqlite-corrupt file has been created.

In some cases, this procedure may allow you to recover the corrupt file along with all of its contents (history).

Close Firefox and ensure it's done closing in your task manager.

Before you proceed, make a backup of the Firefox profile folder, in any case.

Create a folder to use temporarily for this work, such as my_work_folder.
Copy places.sqlite-corrupt from the Firefox profile folder to the work folder.

Download the latest precompiled binary Sqlite command-line shell from:
https://www.sqlite.org/download.html
Extract sqlite3 executable into the work folder.

Open a terminal window and navigate to the work folder.
Then open an sqlite shell:

my_work_folder> sqlite3 places.sqlite-corrupt

sqlite> PRAGMA integrity_check;

If the result IS OK, this guide won't help; stop here and please file a bug.

sqlite> .clone places.sqlite

sqlite> PRAGMA user_version;

Note the version number returned by the last pragma query.

sqlite> .exit

Open a new shell for the new database:

my_work_folder> sqlite3 places.sqlite

sqlite> PRAGMA integrity_check;

If the result IS NOT OK, the file cannot be recovered; stop here and please file a bug.

Let's fix the schema version.
NN must be replaced with the number we had noted previously:

sqlite> PRAGMA user_version = NN;

Let's update the page_size value:

sqlite> PRAGMA journal_mode = truncate;
sqlite> PRAGMA page_size = 32768;
sqlite> VACUUM;
sqlite> PRAGMA journal_mode = wal;
sqlite> .exit

Copy the new places.sqlite to the profile folder, overwriting the existing one.
Remove the places.sqlite-corrupt file.

Launch Firefox.

If the database is still broken (missing history, creating -corrupt file, ...), please file a bug.