# Failed to commit transaction (..\\Library\\MetadataItem.cpp:5052) (tries=1): Cannot commit transaction. database disk image is malformed

**URL:** <https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615>\
**Category:** Plex Media Server\
**Tags:** server-windows\
**Created:** [April 28, 2021, 7:48pm UTC](https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615 "2021-04-28T19:48:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingmotley](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/kingmotley/32/82715_2.png) [@kingmotley](https://forums.plex.tv/u/kingmotley)\
**Post date:** [April 28, 2021, 7:48pm UTC](https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615/1 "2021-04-28T19:48:02Z")

</div>

Seems I managed to get a corrupt sqlite database, and after going through the steps on how fix that ([Repair a Corrupt Database | Plex Support](https://support.plex.tv/articles/201100678-repair-a-corrupt-database/)), I now get: `Failed to commit transaction (..\Library\MetadataItem.cpp:5052) (tries=1): Cannot commit transaction. database disk image is malformed` whenever I try to update any metadata.

The server seems to come up just fine, and I can start watching stuff, but concerned that the problem really isn’t fixed, and I’ll just start having more issues down the road.

---

<div class="post-metadata">

**Author:** ![FordGuy61](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@FordGuy61](https://forums.plex.tv/u/FordGuy61)\
**Post date:** [April 28, 2021, 8:25pm UTC](https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615/2 "2021-04-28T20:25:28Z")

</div>

Pull your log files & look in `Plex Media Server.log` for SQLITE3 errors.

[Settings](https://app.plex.tv/desktop/#!/settings/web/general) → Troubleshooting → Download Logs.

Unzip the file and open the `Plex Media Server.log` file with a text editor/reader.

Look for error messages indicating database corruption, such as those containing `ERROR - SQLITE3` or `ERROR - Database corruption`. Some examples:

```auto
Jul 05, 2020 19:36:56.959 [0x7f59f1b85740] ERROR - SQLITE3:(nil), 11, database corruption at line 64817 of [bf8c1b2b7a]
Jul 05, 2020 19:36:56.959 [0x7f59f1b85740] ERROR - SQLITE3:(nil), 11, statement aborts at 10: [select max(max(metadata_items.changed_at),max(metadata_items.resources_changed_at)) from metadata_items] database disk image is malformed
Jul 05, 2020 19:36:56.978 [0x7f59f1b85740] ERROR - Database corruption: sqlite3_statement_backend::loadOne: database disk image is malformed

```

If the database is corrupt, you’ve three choices: repair, restore from a backup, or delete & start over.

If you delete the database you will have to re-create your libraries and re-share them with any users. Your media is not touched during the process.

If you’ve a backup of the database you can try restoring it. If the backup is not corrupt, you can then re-scan your libraries to pick up any additions since the date of the backup.

You can also try repairing the database. You will need to be comfortable with using Terminal and the command line for this option.

These support articles have additional information:

> **[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...

> **[Repair a Corrupt Database | Plex Support](https://support.plex.tv/articles/201100678-repair-a-corrupt-database/)**
>
> Though rare, it is possible for your main Plex Media Server database to become corrupted. For instance, it might happen...

> **[Reporting issues with Plex Media Server | Plex Support](https://support.plex.tv/articles/201643703-reporting-issues-with-plex-media-server/)**
>
> How to Report an Issue If you believe you have found an issue in Plex Media Server, please report it...

---

<div class="post-metadata">

**Author:** ![kingmotley](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/kingmotley/32/82715_2.png) [@kingmotley](https://forums.plex.tv/u/kingmotley)\
**Post date:** [April 28, 2021, 9:04pm UTC](https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615/3 "2021-04-28T21:04:12Z")

</div>

I did the second “Repair a Corrupt Database”, however I am still getting messages about a corrupt database, which seems wrong since they were just recreated.

I will try restoring, I have a few backups.

---

<div class="post-metadata">

**Author:** ![kingmotley](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/kingmotley/32/82715_2.png) [@kingmotley](https://forums.plex.tv/u/kingmotley)\
**Post date:** [April 28, 2021, 9:41pm UTC](https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615/4 "2021-04-28T21:41:06Z")

</div>

Using the Repair a Corrupt Database did not seem to work, however, restoring the database from 10 days ago did. I had more recent backups, but decided to roll back 10 days because it was easy enough and I didn’t want to have to rollback again (further). System is busy, but content plays, and metadata is editable again, so problem solved.

---

<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:** [July 27, 2021, 9:41pm UTC](https://forums.plex.tv/t/failed-to-commit-transaction-library-metadataitem-cpp-5052-tries-1-cannot-commit-transaction-database-disk-image-is-malformed/712615/5 "2021-07-27T21:41:59Z")

</div>

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