V4 Update SonarrStartupException: Sonarr failed to start: Error creating main database

Sonarr version (exact version):
Mono version (if Sonarr is not running on Windows):
OS: Windows 10
Debug logs:

Description of issue:
New user signed up to post this issue.

I was running v3.0.10.1567 on a Windows 10 machine. I am in the process of replacing the windows pc. I didn’t even realize v4 had come out as I have just been using the app happily for a long time. I made another v3 backup and then attempted to update v3 to v4 in place on the old machine prior to replacement. V4 attempted to migrate the database but fails. The link above has a chunk of log pulled from sonarr.txt as I can no longer get the app to start.

I see the link in the log with the error and the associated JSON exception. But I have no idea how to fix it. I don’t know how to correct the db file in order for the migration to complete. Nor can I roll back as that failed.

Advice on next steps? Thanks.

The DB is sonarr.db, looks like at least one file in the MediaInfo column of EpisodeFiles is invalid and contains 0x0E.

SELECT * FROM EpisodeFiles WHERE MediaInfo LIKE =%0x0E% might yield something, but there could be other issues as well.

I ran the SQL like was posted above (had to remove the = sign) and it returned no results. Looked through most of the tables and couldn’t find anything resembling ‘0x0E’.

I worked through the DB corruption steps in the wiki.
When reimporting the saved SQL file, it didn’t find any issues or constraints.
I ran vacuum and the integrity check came back with ok.
Because no issues were found this doesn’t seem like it did anything.

I found an old install file for on the web. I uninstalled v4 and reinstalled v3.0.10.1567. The existing .db file loaded without issue.

I installed v3.0.10.1567 on the new machine and restored from my backup. It worked fine on the new machine.

What should I look for that is broken in the database? Should I just continue to run on v3.0.10.1567 and defer an upgrade to v4?

It’s something within the MediaInfo column in EpisodeFiles that is corrupt.

You could remove everything from that column: UPDATE EpisodeFiles SET MediaInfo = NULL or '{}' instead of NULL and try upgrading again. When Analyze Media Files is enabled Sonarr will re-extract that information when the series is refreshed/rescanned.

No reason to wait, waiting to upgrade won’t make the JSON in that column any less invalid.

I appreciate the advice. Would the “update all” on the main “series” tab in the v3 UI accomplish the same attempt at refreshing the information, prior to an upgrade to v4?

It wouldn’t be then it all needs to be migrated, whereas doing it in v4 with use ffprobe instead.

I’m having the same exact issue. Long time Sonarr v3 user with hundreds of series. Tried upgrading to v4 (mostly just for dark mode) and greeted with an Epic Fail and it won’t start. Any chance of adding some sort of data sanitizer to the upgrade scripts in the installer? I’m happy to help troubleshoot.