Database Corruption Not Repairing

Server Version#: 1.19.4.2935

Hi everybody,

Unfortunately my Plex database is corrupt, resulting in failed searches, empty playlists, the inability to add new items, or to delete my Music library. I feel like I started having a lot of corruption issues once I added the Music library, and I would repair them using the dump.sql method and everything was fine. However, now the integrity check shows as ‘ok’ and using the dump.sql method is not fixing the issue. By the time I noticed this last issue, it was too late to go back to one of the backup databases, they all have the same issue.

Is there any way I can repair this, or is my only option to re-scan everything and re-create the database? I have around 50 TB of data and several years of play history so I was trying to avoid this if possible. Thank you for any help you may provide!!

Jul 22, 2020 16:25:32.746 [0x7fecc25a1700] WARN - Waited one whole second for a busy database.
Jul 22, 2020 16:25:34.129 [0x7fec7ce31700] ERROR - SQLITE3:(nil), 267, statement aborts at 10: [delete from metadata_items where library_section_id=?] database disk image is malformed
Jul 22, 2020 16:25:34.284 [0x7fec7ce31700] ERROR - Exception inside transaction (inside=1) (../Library/Scanner/LibrarySection.cpp:417): sqlite3_statement_backend::loadOne: database disk image is malformed
Jul 22, 2020 16:25:34.367 [0x7fec7ce31700] ERROR - Thread: Uncaught exception running async task which was spawned by thread 0x7fec7fa23700: sqlite3_statement_backend::loadOne: database disk image is malformed


mast@UltimaThule:/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases$ cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original
mast@UltimaThule:/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases$ sqlite3 com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"
mast@UltimaThule:/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases$ sqlite3 com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"
mast@UltimaThule:/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases$ sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"
ok

Do you have backup DB files?

If so, use the method of:

  1. Stop
  2. Delete SHM and WAL for the main DB
  3. Copy the backup to be the main.
  4. Verify user plex:users has ownership
  5. Start

Hi @ChuckPa, thanks for responding.

I have tried moving to my earliest backup but the issue is still present. Unfortunately, I don’t think I caught this one for a couple weeks.

To confirm I did the proper procedure:

Databases directory prior to the change (I did not have SHM or WAL files?)

mast@UltimaThule:/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases$ ls -l
total 11005280
-rwxrwxrwx+ 1 plex users  396050432 Feb 17  2019 com.plexapp.dlna.db
-rwxrwxrwx+ 1 plex users 1496651776 Jul 22 15:54 com.plexapp.plugins.library.blobs.db
-rwxrwxrwx+ 1 plex users 1496549376 Jul 13 01:02 com.plexapp.plugins.library.blobs.db-2020-07-13
-rwxrwxrwx+ 1 plex users 1496549376 Jul 16 01:04 com.plexapp.plugins.library.blobs.db-2020-07-16
-rwxrwxrwx+ 1 plex users 1496549376 Jul 19 01:07 com.plexapp.plugins.library.blobs.db-2020-07-19
-rwxrwxrwx+ 1 plex users 1496651776 Jul 22 01:07 com.plexapp.plugins.library.blobs.db-2020-07-22
-rwxrwxrwx+ 1 plex users     209920 Apr  4  2017 com.plexapp.plugins.library.blobs.old
-rwxrwxrwx+ 1 plex users  490851328 Jul 22 16:34 com.plexapp.plugins.library.db
-rwxrwxrwx+ 1 plex users  495398912 Jul 13 01:01 com.plexapp.plugins.library.db-2020-07-13
-rwxrwxrwx+ 1 plex users  495707136 Jul 16 01:03 com.plexapp.plugins.library.db-2020-07-16
-rwxrwxrwx+ 1 plex users  495934464 Jul 19 01:03 com.plexapp.plugins.library.db-2020-07-19
-rwxrwxrwx+ 1 plex users  496221184 Jul 22 01:04 com.plexapp.plugins.library.db-2020-07-22
-rwxrwxrwx+ 1 plex users  496248832 Jul 22 15:56 com.plexapp.plugins.library.db.original
-rwxrwxrwx+ 1 plex users  419054862 Jul 22 15:58 dump.sql
drwxrwxrwx+ 1 plex users         48 Jan 13  2019 @eaDir
-rwxrwxrwx+ 1 plex users     750080 Aug 25  2017 sqlite3.exe

Databases directory after the change (I used the 07-13 files)

mast@UltimaThule:/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases$ ls -l
total 11000004
-rwxrwxrwx+ 1 plex users  396050432 Feb 17  2019 com.plexapp.dlna.db
-rwxrwxrwx+ 1 plex users 1496549376 Jul 13 01:02 com.plexapp.plugins.library.blobs.db
-rwxrwxrwx+ 1 plex users 1496549376 Jul 16 01:04 com.plexapp.plugins.library.blobs.db-2020-07-16
-rwxrwxrwx+ 1 plex users 1496549376 Jul 19 01:07 com.plexapp.plugins.library.blobs.db-2020-07-19
-rwxrwxrwx+ 1 plex users 1496651776 Jul 22 01:07 com.plexapp.plugins.library.blobs.db-2020-07-22
-rwxrwxrwx+ 1 plex users 1496651776 Jul 22 15:54 com.plexapp.plugins.library.blobs.db-722backup
-rwxrwxrwx+ 1 plex users     209920 Apr  4  2017 com.plexapp.plugins.library.blobs.old
-rwxrwxrwx+ 1 plex users  495398912 Jul 13 01:01 com.plexapp.plugins.library.db
-rwxrwxrwx+ 1 plex users  495707136 Jul 16 01:03 com.plexapp.plugins.library.db-2020-07-16
-rwxrwxrwx+ 1 plex users  495934464 Jul 19 01:03 com.plexapp.plugins.library.db-2020-07-19
-rwxrwxrwx+ 1 plex users  496221184 Jul 22 01:04 com.plexapp.plugins.library.db-2020-07-22
-rwxrwxrwx+ 1 plex users  490847232 Jul 22 17:27 com.plexapp.plugins.library.db-722backup
-rwxrwxrwx+ 1 plex users  490851328 Jul 22 16:36 com.plexapp.plugins.library.db.original
-rwxrwxrwx+ 1 plex users  419054862 Jul 22 15:58 dump.sql
drwxrwxrwx+ 1 plex users         48 Jan 13  2019 @eaDir
-rwxrwxrwx+ 1 plex users     750080 Aug 25  2017 sqlite3.exe

Errors in the Plex Media Server.log afterwards

Jul 22, 2020 17:39:34.726 [0x7f5300567700] ERROR - SQLITE3:(nil), 1, statement aborts at 1: [COMMIT] cannot commit - no transaction is active
Jul 22, 2020 17:39:34.726 [0x7f5300567700] ERROR - Failed to commit transaction (../Library/MetadataItem.cpp:1019) (tries=6): Cannot commit transaction. cannot commit - no transaction is active
Jul 22, 2020 17:39:35.702 [0x7f5300567700] ERROR - SQLITE3:(nil), 1, statement aborts at 1: [COMMIT] cannot commit - no transaction is active
Jul 22, 2020 17:39:35.702 [0x7f5300567700] ERROR - Failed to commit transaction (../Library/MetadataItem.cpp:1019) (tries=7): Cannot commit transaction. cannot commit - no transaction is active

Still not able to look at my playlists and many searches return no results when they should. i.e. I searched for ‘star’ but did not see Star Trek, Star Wars, etc.

It did pick up on some new TV show files and add them, which I did not think I was able to add anything to the library before. (one of the ways I noticed an issue)

Let’s try this.

It will save what you have, possibly allowing us to extract some info later.

  1. Stop Plex
  2. Open the Plex share
  3. Rename Library to Library.old
  4. Go back to Plex/web
  5. Upper right corner -> Sign out of your Plex account
  6. Start Plex
  7. Open the server and start to setup a new instance.
    HOWEVER
  8. Give it a different “Friendly Name” as you do which is different than you have now.
  9. Doing so keeps Plex/Web and Plex.tv from trying to merge the two and causing problems when rebuilding on the same IP.
    10… Create one library section and test a bit
  10. Let me know your findings.

I’m not sure when it corrupted or if it corrupted before the first backup. Something is very off because PMS doesn’t delete database backups.

Okay, I followed these instructions and created a new server named “Enceladus” (my old one is named UltimaThule)

I added my Movies library since it’s much smaller than the TV Shows and it looks like everything has added, is searchable, etc. I don’t see any database errors in the logs. Of course, everything is fresh with no play history or playlists, different posters than I had in the other library, etc. Is this my only option at this point?

When you did the .dump method, did you delete the specific indicies before dumping it (as indicated in the support page) ?

Yes I followed each step every time. At some point, there were no longer SHM or WAL files so I no longer had to perform that check.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.