# Database/Index Corruption & database disk image is malformed

**URL:** <https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055>\
**Category:** Plex Media Server\
**Tags:** server-mac\
**Created:** [August 9, 2021, 3:50pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055 "2021-08-09T15:50:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alimbocl](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@alimbocl](https://forums.plex.tv/u/alimbocl)\
**Post date:** [August 9, 2021, 3:50pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055/1 "2021-08-09T15:50:48Z")

</div>

Server Version#: 1.24.0.4921 running on Mac OS 11.5.1

Recently I’ve started to get notifications that my PMS database is corrupted. When I look in [PMS logs](https://support.plex.tv/articles/200250417-plex-media-server-log-files/) I see the below. I tried following the steps documented here [Repair a Corrupted Database | Plex Support](https://support.plex.tv/articles/repair-a-corrupted-database/) but there was no noticeable change. When I check for corruption the return is OK. When I attempt to recover the database the output file is very small and only contains the following lines (regardless if an output file or not is specified).

PRAGMA foreign\_keys=OFF;  
BEGIN;  
PRAGMA writable\_schema = on;  
PRAGMA writable\_schema = off;  
COMMIT;

```auto
Aug 09, 2021 11:09:34.610 [0x7000099e8000] ERROR - SQLITE3:(nil), 779, index corruption at line 91877 of [1b256d97b5]
Aug 09, 2021 11:09:34.610 [0x7000099e8000] ERROR - SQLITE3:(nil), 779, statement aborts at 66: [update metadata_item_settings set account_id=:metadata_item_settings_account_id,guid=:metadata_item_settings_guid,rating=:metadata_item_settings_rating,view_offset=:metadata_item_setti
Aug 09, 2021 11:09:34.610 [0x7000099e8000] ERROR - Exception inside transaction (inside=1) (/data/jenkins/server/1782715324/Library/MetadataItem.cpp:11736): sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 09, 2021 11:09:34.610 [0x7000099e8000] ERROR - Soci Exception handled: sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 09, 2021 11:09:37.986 [0x70000a3a1000] WARN - QueryParser: Invalid field 'subtype' found, ignoring.
Aug 09, 2021 11:09:37.986 [0x70000a3a1000] WARN - QueryParser: Invalid field 'smart' found, ignoring.
Aug 09, 2021 11:09:42.253 [0x7000099e8000] ERROR - SQLITE3:(nil), 779, index corruption at line 91877 of [1b256d97b5]
Aug 09, 2021 11:09:42.253 [0x7000099e8000] ERROR - SQLITE3:(nil), 779, statement aborts at 66: [update metadata_item_settings set account_id=:metadata_item_settings_account_id,guid=:metadata_item_settings_guid,rating=:metadata_item_settings_rating,view_offset=:metadata_item_setti
Aug 09, 2021 11:09:42.253 [0x7000099e8000] ERROR - Exception inside transaction (inside=1) (/data/jenkins/server/1782715324/Library/MetadataItem.cpp:11736): sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 09, 2021 11:09:42.255 [0x7000099e8000] ERROR - Soci Exception handled: sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 09, 2021 11:09:54.597 [0x7000099e8000] WARN - QueryParser: Invalid field 'subtype' found, ignoring.
Aug 09, 2021 11:09:54.597 [0x7000099e8000] WARN - QueryParser: Invalid field 'smart' found, ignoring.
Aug 09, 2021 11:10:01.880 [0x7000099e8000] WARN - QueryParser: Invalid field 'subtype' found, ignoring.
Aug 09, 2021 11:10:01.880 [0x7000099e8000] WARN - QueryParser: Invalid field 'smart' found, ignoring.
Aug 09, 2021 11:10:03.882 [0x7000099e8000] WARN - QueryParser: Invalid field 'subtype' found, ignoring.
Aug 09, 2021 11:10:03.882 [0x7000099e8000] WARN - QueryParser: Invalid field 'smart' found, ignoring.
Aug 09, 2021 11:10:10.775 [0x700009e00000] ERROR - SQLITE3:(nil), 779, index corruption at line 91877 of [1b256d97b5]
Aug 09, 2021 11:10:10.775 [0x700009e00000] ERROR - SQLITE3:(nil), 779, statement aborts at 66: [update metadata_item_settings set account_id=:metadata_item_settings_account_id,guid=:metadata_item_settings_guid,rating=:metadata_item_settings_rating,view_offset=:metadata_item_setti
Aug 09, 2021 11:10:10.775 [0x700009e00000] ERROR - Exception inside transaction (inside=1) (/data/jenkins/server/1782715324/Library/MetadataItem.cpp:11736): sqlite3_statement_backend::loadOne: database disk image is malformed

```

[Plex Media Server.1.log](https://forums.plex.tv/uploads/short-url/4xcqDGvSwd3lmoIDQ8SoTZrCnBD.log) (3.7 KB)  
[Plex Media Server.2.log](https://forums.plex.tv/uploads/short-url/iM0JFI0NbnPMrDV5HKnfJ9G6X3p.log) (9.6 KB)  
[Plex Media Server.3.log](https://forums.plex.tv/uploads/short-url/81zw0aCot1knS4Gh8ehllGer7eQ.log) (13.4 KB)  
[Plex Media Server.4.log](https://forums.plex.tv/uploads/short-url/1nu9UTkFH0tlumZwwH3oaePHsZl.log) (4.9 KB)  
[Plex Media Server.5.log](https://forums.plex.tv/uploads/short-url/19ZUSRwHZAuZAmJqH1EEP7sKADp.log) (3.5 KB)  
[Plex Media Server.log](https://forums.plex.tv/uploads/short-url/oFRjM0vy2XmybrOzXBY7VAXoWJy.log) (2.7 KB)

---

<div class="post-metadata">

**Author:** ![pshanew](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/pshanew/32/160555_2.png) [@pshanew](https://forums.plex.tv/u/pshanew)\
**Post date:** [August 9, 2021, 4:44pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055/2 "2021-08-09T16:44:37Z")

</div>

It’s possible that the current database is so badly damaged that it cannot be repaired. If that’s the case, you may need to try to restore a backup of your database; by default, Plex Media Server will create a backup every three days. This article describes the restoration process:

> **[Restore a Database Backed Up via 'Scheduled Tasks' | Plex Support](https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/)**
>
> One of the many Scheduled Tasks that a Plex Media Server performs is to make regular backups of the core...

Dependent upon how recently you noticed this problem, you may need to restore an older database.

---

<div class="post-metadata">

**Author:** ![alimbocl](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@alimbocl](https://forums.plex.tv/u/alimbocl)\
**Post date:** [August 9, 2021, 5:59pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055/3 "2021-08-09T17:59:44Z")

</div>

My last database backup was from the end of June so I was able to restore using that. Is there a way I can clear the logs out?

---

<div class="post-metadata">

**Author:** ![pshanew](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/pshanew/32/160555_2.png) [@pshanew](https://forums.plex.tv/u/pshanew)\
**Post date:** [August 9, 2021, 6:12pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055/4 "2021-08-09T18:12:04Z")

</div>

> [@alimbocl](#):
>
> Is there a way I can clear the logs out?

Via Plex? I don’t believe so. I think you’ll just have to delete them from:  
`/Users/username/Library/Logs/Plex Media Server/`

---

<div class="post-metadata">

**Author:** ![alimbocl](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@alimbocl](https://forums.plex.tv/u/alimbocl)\
**Post date:** [August 9, 2021, 6:13pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055/5 "2021-08-09T18:13:34Z")

</div>

That’s fine, I can delete them through there. Wanted to get fresh logs after the database restore and take a look. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [November 7, 2021, 6:13pm UTC](https://forums.plex.tv/t/database-index-corruption-database-disk-image-is-malformed/735055/6 "2021-11-07T18:13:57Z")

</div>

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