Database corrupt

Server Version#: 1.22.2.4282
Player Version#: 8.15.2.24006

For about two weeks I received a notification on the phone (where I installed PlexAmp) that show a message “database is corrupt”.
I followed the instructions found here https://support.plex.tv/articles/201100678-repair-a-corrupt-database/ to repair it.

I downloaded the DB on my PC (Win10), I checked the DB and tried to repair it with SQLite Tools, but it is not possible.

The error shown is the following:
Error: near line 156218: no such collation sequence: icu_root

Line is this:
CREATE INDEX ‘index_title_sort_icu’ ON ‘metadata_items’ (‘title_sort’ COLLATE icu_root);

My Linux server is mounted by docker on Openmediavault.

Plex continues to run smoothly, but the notification keeps appearing.

Someone can help me?

Regards.
Davide.

1 Like

Nobody can help me?

Hi davide.falchetto, I have the same problem as you. Plex server is running in a docker on OpenMediaVault. I tried to repair the database to no success. I tried to find other ways to fix the database but still no success.

I’m thinking of just deleting all the metadata and restarting the server from a fresh start.

You will want use the instructions posted here -

@hthighway this is the response of a team member in that post:

There is already an open ticket about updating the procedure.
I haven’t spoken to the folks who do documentation but usually updated documentation goes live when software goes Public.

https://forums.plex.tv/t/hoping-for-help-with-db-corruption/701344/19

The problem seems not to have been solved yet.

Of course, if someone from the team made themselves heard here too…

Then there is another problem: when I click on DOWNLOAD DATABASE in Settings → Troubleshooting the generated zip file is completely empty. :expressionless: :expressionless: :expressionless:

You would probably be better off trying to restore the database from a recent backup copy. Have you tried this?

I tried to restore. Same problem …

Is it possible that there is no solution to this problem? :face_with_raised_eyebrow:

I opened up the dump file, deleted the problematic line, and imported the dump. Plex recovered. Haven’t noticed any issues yet.

This applies to Plex Server versions from 1.22.x on:

If you want to repair a database from a non-Windows Plex server on a Windows machine, you need to install Plex Server onto that machine. This is because PMS brings a customized version of the sqlite tools which has support for the ICU extension, so the error message about the no such collation sequence: icu_root doesn’t appear.

Further, you need to follow a new set of steps for a successful repair: Repair a Corrupted Database | Plex Support

Thanks for your reply @Kijette and @OttoKerner

For @Kijette: can you explain to me the procedure you performed?

For @OttoKerner: I install PMS in Windows and then how do I proceed?
Do I copy the database file to the Windows folder and perform the repair attempt with the instructions on the page " Repair a Corrupted Database" ?

I’ve got no experience with openmediavault, but if it’s like any other docker then you can do the following on the Linux box you have plex running on

(assuming the container running plex is called plex)

#stop the plex container
docker stop plex

# copy the plex executable out of the container to a folder of your choosing
docker cp plex:/usr/lib/plexmediaserver/. /to/some/folder

# enter the folder containing the plex DB
cd "/your/path/to/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases"

# remove shm and wal if exists
rm com.plexapp.plugins.library.db-shm
rm com.plexapp.plugins.library.db-wal

#make a copy of the DB just in case
cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original 

#dump the DB to a file
"/to/some/folder/Plex Media Server" --sqlite com.plexapp.plugins.library.db ".output dump.sql" ".dump"

#delete existing DB
rm com.plexapp.plugins.library.db

#import dump.sql 
"/to/some/folder/Plex Media Server" --sqlite com.plexapp.plugins.library.db ".read dump.sql"

#You are all done, start plex back up
docker start plex

Once you are happy it is running you can remove the dump.sql and com.plexapp.plugins.library.db.original files

Precisely that.

Thanks @hthighway!

Later I try :wink:

Thanks again @OttoKerner !

Hi mate!

Today I try @hthighway method.
When I rewrite the database by importing the dump I get a series of errors like this:


Error: near line 178397: UNIQUE constraint failed: fts4_tag_titles_icu_docsize.docid
Error: near line 178398: UNIQUE constraint failed: fts4_tag_titles_icu_docsize.docid
Error: near line 178399: UNIQUE constraint failed: fts4_tag_titles_icu_docsize.docid


Error: near line 179214: UNIQUE constraint failed: activities.id
Error: near line 179215: UNIQUE constraint failed: activities.id
Error: near line 179216: UNIQUE constraint failed: activities.id


Error: near line 179260: index index_media_parts_on_directory_id already exists
Error: near line 179261: index index_media_parts_on_media_item_id already exists
Error: near line 179262: index index_media_parts_on_hash already exists
Error: near line 179263: index index_media_parts_on_file already exists
Error: near line 179264: index index_library_sections_on_name_sort already exists
Error: near line 179265: index index_library_sections_on_name already exists
Error: near line 179266: index index_metadata_item_views_on_guid already exists
Error: near line 179267: index index_metadata_item_views_on_library_section_id already exists
Error: near line 179268: index index_metadata_item_views_on_viewed_at already exists
Error: near line 179269: index index_tags_on_tag already exists
Error: near line 179270: index index_tags_on_tag_type already exists
Error: near line 179271: index index_taggings_on_metadata_item_id already exists
Error: near line 179272: index index_taggings_on_tag_id already exists
Error: near line 179273: index index_metadata_relations_on_metadata_item_id already exists
Error: near line 179274: index index_metadata_relations_on_related_metadata_item_id already exists
Error: near line 179275: index index_metadata_relations_on_relation_type already exists
Error: near line 179276: index index_view_settings_on_view_group already exists
Error: near line 179277: index index_view_settings_on_client_type already exists
Error: near line 179278: index index_library_section_permissions_on_library_section_id already exists
Error: near line 179279: index index_library_section_permissions_on_account_id already exists
Error: near line 179280: index index_plugin_permissions_on_plugin_id already exists
Error: near line 179281: index index_plugin_permissions_on_account_id already exists
Error: near line 179282: index index_metadata_item_settings_on_account_id already exists
Error: near line 179283: index index_metadata_item_settings_on_guid already exists
Error: near line 179284: index index_library_timeline_entries_on_library_section_id already exists
Error: near line 179285: index index_library_timeline_entries_on_metadata_item_id already exists
Error: near line 179286: index index_library_timeline_entries_on_state already exists
Error: near line 179287: index index_library_timeline_entries_on_updated_at already exists
Error: near line 179288: index index_accounts_on_name already exists
Error: near line 179289: index index_media_item_settings_on_account_id already exists
Error: near line 179290: index index_media_item_settings_on_media_item_id already exists
Error: near line 179291: index index_media_part_settings_on_account_id already exists
Error: near line 179292: index index_media_part_settings_on_media_part_id already exists
Error: near line 179293: index index_media_parts_on_deleted_at already exists
Error: near line 179294: index index_directories_on_deleted_at already exists
Error: near line 179295: index index_media_streams_on_media_part_id already exists
Error: near line 179296: index index_synchronization_files_on_client_identifier already exists
Error: near line 179297: index index_synchronization_files_on_sync_list_id already exists
Error: near line 179298: index index_synchronization_files_on_sync_item_id already exists
Error: near line 179299: index index_synchronization_files_on_item_uri already exists
Error: near line 179300: index index_media_items_on_library_section_id already exists
Error: near line 179301: index index_media_items_on_metadata_item_id already exists
Error: near line 179302: index index_media_items_on_deleted_at already exists
Error: near line 179303: index index_media_items_on_media_analysis_version already exists
Error: near line 179304: index index_metadata_items_on_library_section_id already exists
Error: near line 179305: index index_metadata_items_on_parent_id already exists
Error: near line 179306: index index_metadata_items_on_created_at already exists
Error: near line 179307: index index_metadata_items_on_index already exists
Error: near line 179308: index index_metadata_items_on_title already exists
Error: near line 179309: index index_metadata_items_on_title_sort already exists
Error: near line 179310: index index_metadata_items_on_guid already exists
Error: near line 179311: index index_metadata_items_on_metadata_type already exists
Error: near line 179312: index index_metadata_items_on_deleted_at already exists
Error: near line 179313: index index_metadata_items_on_library_section_id_and_metadata_type_and_added_at already exists
Error: near line 179314: index unique_schema_migrations already exists
Error: near line 179315: index index_metadata_items_on_hash already exists
Error: near line 179316: index index_cloudsync_files_on_device_identifier_and_original_url already exists
Error: near line 179317: index index_plugin_prefixes_on_plugin_id already exists
Error: near line 179318: index index_media_streams_on_media_item_id already exists
Error: near line 179319: index index_media_parts_on_size already exists
Error: near line 179320: index index_directories_on_path already exists
Error: near line 179321: index index_play_queue_items_on_play_queue_id already exists
Error: near line 179322: index index_play_queue_items_on_metadata_item_id already exists
Error: near line 179323: index index_play_queue_items_on_order already exists
Error: near line 179324: index index_play_queues_on_account_id already exists
Error: near line 179325: index index_play_queues_on_playlist_id already exists
Error: near line 179326: index index_play_queues_on_sync_item_id already exists
Error: near line 179327: index index_play_queue_generators_on_playlist_id already exists
Error: near line 179328: index index_play_queue_generators_on_metadata_item_id already exists
Error: near line 179329: index index_play_queue_generators_on_order already exists
Error: near line 179330: index index_play_queues_on_client_identifier_and_account_id_and_metadata_type already exists
Error: near line 179331: index index_media_streams_on_language already exists
Error: near line 179332: index index_metadata_item_accounts_on_account_id already exists
Error: near line 179333: index index_metadata_item_accounts_on_metadata_item_id already exists
Error: near line 179334: index index_metadata_items_on_added_at already exists
Error: near line 179335: index index_metadata_item_settings_on_view_count already exists
Error: near line 179336: index index_metadata_item_settings_on_view_offset already exists
Error: near line 179337: index index_metadata_item_settings_on_skip_count already exists
Error: near line 179338: index index_metadata_item_settings_on_rating already exists
Error: near line 179339: index index_metadata_item_settings_on_last_viewed_at already exists
Error: near line 179340: index index_metadata_items_on_originally_available_at already exists
Error: near line 179341: index index_synced_play_queue_generators_on_sync_list_id already exists
Error: near line 179342: index index_synced_play_queue_generators_on_sync_item_id already exists
Error: near line 179343: index index_synced_play_queue_generators_on_playlist_id already exists
Error: near line 179344: index index_synced_play_queue_generators_on_play_queue_generator_id already exists
Error: near line 179345: index index_synced_play_queue_generators_on_changed_at already exists
Error: near line 179346: index index_synced_play_queue_generators_on_state already exists
Error: near line 179347: index index_synced_play_queue_generators_on_sync_list_id_and_play_queue_generator_id already exi
Error: near line 179348: index index_synced_ancestor_items_on_sync_list_id already exists
Error: near line 179349: index index_synced_ancestor_items_on_metadata_item_id already exists
Error: near line 179350: index index_synced_ancestor_items_on_changed_at already exists
Error: near line 179351: index index_synced_ancestor_items_on_reference_count already exists
Error: near line 179352: index index_synced_ancestor_items_on_sync_list_id_and_metadata_item_id already exists
Error: near line 179353: index index_synced_library_sections_on_sync_list_id already exists
Error: near line 179354: index index_synced_library_sections_on_library_section_id already exists
Error: near line 179355: index index_synced_library_sections_on_changed_at already exists
Error: near line 179356: index index_synced_library_sections_on_reference_count already exists
Error: near line 179357: index index_synced_library_sections_on_sync_list_id_and_library_section_id already exists
Error: near line 179358: index index_metadata_items_on_changed_at already exists
Error: near line 179359: index index_metadata_items_on_resources_changed_at already exists
Error: near line 179360: index index_play_queue_generators_on_changed_at already exists
Error: near line 179361: index index_library_sections_on_changed_at already exists
Error: near line 179362: index index_metadata_item_settings_on_changed_at already exists
Error: near line 179363: index index_media_part_settings_on_changed_at already exists
Error: near line 179364: index index_tags_on_tag_type_and_tag already exists
Error: near line 179365: index index_synced_metadata_items_on_sync_list_id already exists
Error: near line 179366: index index_synced_metadata_items_on_sync_item_id already exists
Error: near line 179367: index index_synced_metadata_items_on_metadata_item_id already exists
Error: near line 179368: index index_synced_metadata_items_on_changed_at already exists
Error: near line 179369: index index_synced_metadata_items_on_first_packaged_at already exists
Error: near line 179370: index index_synced_metadata_items_on_state already exists
Error: near line 179371: index index_synced_metadata_items_on_sync_list_id_and_metadata_item_id already exists
Error: near line 179372: index index_sync_schema_versions_on_changed_at already exists
Error: near line 179373: index index_versioned_metadata_items_on_metadata_item_id already exists
Error: near line 179374: index index_versioned_metadata_items_on_generator_id already exists
Error: near line 179375: index index_versioned_metadata_items_on_target_tag_id already exists
Error: near line 179376: index index_versioned_metadata_items_on_version_media_id already exists
Error: near line 179377: index index_versioned_metadata_items_on_selected_media_id already exists
Error: near line 179378: index index_preferences_on_name already exists
Error: near line 179379: index index_devices_on_identifier already exists
Error: near line 179380: index spellfix_metadata_titles_vocab_index_langid_k2 already exists
Error: near line 179381: index spellfix_tag_titles_vocab_index_langid_k2 already exists
Error: near line 179382: index index_metadata_items_on_original_title already exists
Error: near line 179383: index index_metadata_item_views_on_grandparent_guid already exists
Error: near line 179384: index index_synced_metadata_items_parent_id already exists
Error: near line 179385: index index_synced_metadata_items_library_section_id already exists
Error: near line 179386: index index_synced_ancestor_items_parent_id already exists
Error: near line 179387: index index_synced_ancestor_items_state already exists
Error: near line 179388: index index_synced_library_sections_state already exists
Error: near line 179389: index index_tags_on_key already exists
Error: near line 179390: index index_media_items_on_begins_at already exists
Error: near line 179391: index index_media_items_on_ends_at already exists
Error: near line 179392: index index_media_items_on_channel_id already exists
Error: near line 179393: index index_media_items_on_channel_id_and_begins_at already exists
Error: near line 179394: index media_provider_resources_on_uuid already exists
Error: near line 179395: index media_provider_resources_on_parent_id already exists
Error: near line 179396: index media_provider_resources_on_type already exists
Error: near line 179397: index media_provider_resources_on_identifier already exists
Error: near line 179398: index media_subscriptions_on_order already exists
Error: near line 179399: index media_subscriptions_on_target_metadata_item_id already exists
Error: near line 179400: index media_grabs_on_uuid already exists
Error: near line 179401: index media_grabs_on_metadata_item_id already exists
Error: near line 179402: index media_grabs_on_created_at already exists
Error: near line 179403: index index_metadata_item_clusters_on_library_section_id already exists
Error: near line 179404: index index_metadata_item_clusters_on_zoom_level already exists
Error: near line 179405: index index_metadata_item_clusters_on_title already exists
Error: near line 179406: index index_metadata_item_clusterings_on_metadata_item_id already exists
Error: near line 179407: index index_metadata_item_clusterings_on_metadata_item_cluster_id already exists
Error: near line 179408: index index_metadata_item_clusterings_on_version already exists
Error: near line 179409: index index_metadata_items_on_absolute_index already exists
Error: near line 179410: index index_locatables_on_location_id_and_locatable_id_and_locatable_type already exists
Error: near line 179411: index index_locatables_on_locatable_id_and_locatable_type already exists
Error: near line 179412: index index_blobs_on_linked_type already exists
Error: near line 179413: index index_tags_on_parent_id already exists
Error: near line 179414: index index_location_places_on_location_id_and_guid already exists
Error: near line 179415: index index_locatables_on_geocoding_version already exists
Error: near line 179416: index index_external_metadata_sources_on_uri already exists
Error: near line 179417: index index_external_metadata_sources_on_online already exists
Error: near line 179418: index index_external_metadata_items_on_external_source_id already exists
Error: near line 179419: index index_external_metadata_items_on_title already exists
Error: near line 179420: index index_external_metadata_items_on_parent_title already exists
Error: near line 179421: index index_external_metadata_items_on_metadata_type already exists
Error: near line 179422: index index_media_stream_settings_on_media_stream_id_and_account_id already exists
Error: near line 179423: index index_statistics_resources_on_timespan already exists
Error: near line 179424: index index_statistics_resources_on_at already exists
Error: near line 179425: index index_metadata_items_on_remote already exists
Error: near line 179426: index index_metadata_subscription_desired_items_on_sub_id already exists
Error: near line 179427: index index_metadata_subscription_desired_items_on_remote_id already exists
Error: near line 179428: index index_directories_on_parent_directory_id already exists
Error: near line 179429: index remote_id_translation_on_local_id already exists
Error: near line 179430: index remote_id_translation_on_remote_id already exists
Error: near line 179431: index index_statistics_bandwidth_on_at already exists
Error: near line 179432: index index_statistics_media_on_at already exists
Error: near line 179433: index index_statistics_bandwidth_on_account_id_and_timespan_and_at already exists
Error: near line 179434: index index_statistics_media_on_account_id_and_timespan_and_at already exists
Error: near line 179435: index index_blobs_on_linked_type_linked_id_and_blob_type already exists
Error: near line 179436: index index_blobs_on_linked_type_linked_guid_and_blob_type already exists
Error: near line 179437: index index_hub_templates_on_section_and_home_visibility already exists
Error: near line 179438: index index_title_sort_icu already exists
Error: near line 179439: index index_activities_on_parent_id already exists
Error: near line 179440: index index_activities_on_started_at already exists
Error: near line 179441: trigger fts4_metadata_titles_before_update_icu already exists
Error: near line 179442: trigger fts4_metadata_titles_before_delete_icu already exists
Error: near line 179443: trigger fts4_metadata_titles_after_update_icu already exists
Error: near line 179444: trigger fts4_metadata_titles_after_insert_icu already exists
Error: near line 179445: trigger fts4_tag_titles_before_update_icu already exists
Error: near line 179446: trigger fts4_tag_titles_before_delete_icu already exists
Error: near line 179447: trigger fts4_tag_titles_after_update_icu already exists
Error: near line 179448: trigger fts4_tag_titles_after_insert_icu already exists

Once plex is restarted via docker, Plex does not launch.
The following error is reported in the docker log file:
Error: Unable to set up server: sqlite3_statement_backend::prepare: malformed database schema (spellfix_metadata_titles) - table spellfix_metadata_titles already exists for SQL: PRAGMA cache_size=2000 (N4soci10soci_errorE).

By restoring the corrupted db, everything starts working again.

Are you importing back into a blank database? Looks like you are importing back into the same one.

Alternatively, you could try the 1 step repair mentioned in that article, which avoids switching databases around. Of course, make a backup before starting.

"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db ".output recover.out" ".recover"

Thank @anon18523487 !

Today I tried your method, adapting it to the Linux docker environment.
These are the steps used:

# Stop the Plex container
docker stop plex

# Copy the Plex executable out of the container to a folder of your choosing
docker cp plex:/usr/lib/plexmediaserver/. /plexTEMP

# Enter the folder containing the Plex DB
cd [/your/path/to/plex]/Library/Application Support/Plex Media Server/Plug-in Support/Databases

# Make a copy of the DB for security
cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original 

# Check DB integrity
/plexTEMP/Plex Media Server --sqlite com.plexapp.plugins.library.db "PRAGMA integrity_check"

# Repair DB
/plexTEMP/Plex Media Server --sqlite com.plexapp.plugins.library.db ".output recover.out" ".recover"

#Restart Plex
docker start plex

At the end, I obviously deleted the “/plexTEMP” directory and the “recover.out” file created in the folder containing the Plex DB.

Once restarted, Plex works fine and in the folder containing the Plex DB, com.plexapp.plugins.library.db-shm and com.plexapp.plugins.library.db-wal files were also created.

The only problem left is that in the docker boot log I encounter this problem:
Critical: libusb_init failed

I hope with this that I have definitively solved the problem :wink:

Thanks to everyone who wanted to try to help me!

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