Server Version#: 1.24.1.4931
Player Version#: N/A
After doing a library scan and being prompted to upgrade my library, there were several items that the library scan got stuck on and would not get past. I let the process run for tens of minutes, but it never completed, and just kept consuming more memory. The plex logs showed it stuck trying to update metadata for one of the movie entries:
Aug 25, 2021 22:56:15.855 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 545 deleted
Aug 25, 2021 22:56:15.855 [0x7fda73342b38] Debug β Deleting media item 62385.
Aug 25, 2021 22:56:15.856 [0x7fda73342b38] Debug β Was connected to metadata item 28630, count is now 2.
Aug 25, 2021 22:56:15.857 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28630, is has a dead item count of 0.
Aug 25, 2021 22:56:15.857 [0x7fda73342b38] Debug β Deleting media item 62386.
Aug 25, 2021 22:56:15.858 [0x7fda73342b38] Debug β Was connected to metadata item 28630, count is now 1.
Aug 25, 2021 22:56:15.859 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28630, is has a dead item count of 0.
Aug 25, 2021 22:56:15.859 [0x7fda73342b38] Debug β Deleting media item 62387.
Aug 25, 2021 22:56:15.860 [0x7fda73342b38] Debug β Was connected to metadata item 28630, count is now 0.
Aug 25, 2021 22:56:15.860 [0x7fda73342b38] Debug β Destroying metadata item 28630 (The Hobbit: The Desolation Of Smaug: I Found Something)
Aug 25, 2021 22:56:15.942 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 546 deleted
Aug 25, 2021 22:56:15.942 [0x7fda73342b38] Debug β Deleting media item 62388.
Aug 25, 2021 22:56:15.943 [0x7fda73342b38] Debug β Was connected to metadata item 28631, count is now 2.
Aug 25, 2021 22:56:15.943 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28631, is has a dead item count of 0.
Aug 25, 2021 22:56:15.943 [0x7fda73342b38] Debug β Deleting media item 62389.
Aug 25, 2021 22:56:15.944 [0x7fda73342b38] Debug β Was connected to metadata item 28631, count is now 1.
Aug 25, 2021 22:56:15.945 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28631, is has a dead item count of 0.
Aug 25, 2021 22:56:15.945 [0x7fda73342b38] Debug β Deleting media item 62390.
Aug 25, 2021 22:56:15.946 [0x7fda73342b38] Debug β Was connected to metadata item 28631, count is now 0.
Aug 25, 2021 22:56:15.947 [0x7fda73342b38] Debug β Destroying metadata item 28631 (The Hobbit: The Desolation Of Smaug: Ian Mckellan)
Aug 25, 2021 22:56:16.028 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 547 deleted
Aug 25, 2021 22:56:16.028 [0x7fda73342b38] Debug β Deleting media item 62582.
Aug 25, 2021 22:56:16.029 [0x7fda73342b38] Debug β Was connected to metadata item 28632, count is now 2.
Aug 25, 2021 22:56:16.029 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28632, is has a dead item count of 0.
Aug 25, 2021 22:56:16.029 [0x7fda73342b38] Debug β Deleting media item 62583.
Aug 25, 2021 22:56:16.030 [0x7fda73342b38] Debug β Was connected to metadata item 28632, count is now 1.
Aug 25, 2021 22:56:16.031 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28632, is has a dead item count of 0.
Aug 25, 2021 22:56:16.031 [0x7fda73342b38] Debug β Deleting media item 62584.
Aug 25, 2021 22:56:16.032 [0x7fda73342b38] Debug β Was connected to metadata item 28632, count is now 0.
Aug 25, 2021 22:56:16.033 [0x7fda73342b38] Debug β Destroying metadata item 28632 (The Hobbit: The Desolation Of Smaug: Benedict Cumberbatch)
Aug 25, 2021 22:56:16.116 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 548 deleted
Aug 25, 2021 22:56:16.116 [0x7fda73342b38] Debug β Deleting media item 62394.
Aug 25, 2021 22:56:16.117 [0x7fda73342b38] Debug β Was connected to metadata item 28633, count is now 2.
Aug 25, 2021 22:56:16.118 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28633, is has a dead item count of 0.
Aug 25, 2021 22:56:16.118 [0x7fda73342b38] Debug β Deleting media item 62395.
Aug 25, 2021 22:56:16.119 [0x7fda73342b38] Debug β Was connected to metadata item 28633, count is now 1.
Aug 25, 2021 22:56:16.120 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28633, is has a dead item count of 0.
Aug 25, 2021 22:56:16.120 [0x7fda73342b38] Debug β Deleting media item 62396.
Aug 25, 2021 22:56:16.121 [0x7fda73342b38] Debug β Was connected to metadata item 28633, count is now 0.
Aug 25, 2021 22:56:16.121 [0x7fda73342b38] Debug β Destroying metadata item 28633 (The Hobbit: The Desolation Of Smaug: You Have No Right)
Aug 25, 2021 22:56:16.202 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 549 deleted
Aug 25, 2021 22:56:16.202 [0x7fda73342b38] Debug β Deleting media item 62397.
Aug 25, 2021 22:56:16.203 [0x7fda73342b38] Debug β Was connected to metadata item 28634, count is now 1.
Aug 25, 2021 22:56:16.204 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28634, is has a dead item count of 0.
Aug 25, 2021 22:56:16.204 [0x7fda73342b38] Debug β Deleting media item 62398.
Aug 25, 2021 22:56:16.205 [0x7fda73342b38] Debug β Was connected to metadata item 28634, count is now 0.
Aug 25, 2021 22:56:16.205 [0x7fda73342b38] Debug β Destroying metadata item 28634 (The Hobbit: The Desolation Of Smaug: Stephen Fry)
Aug 25, 2021 22:56:16.287 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 550 deleted
Aug 25, 2021 22:56:16.287 [0x7fda73342b38] Debug β Deleting media item 62399.
Aug 25, 2021 22:56:16.288 [0x7fda73342b38] Debug β Was connected to metadata item 28635, count is now 1.
Aug 25, 2021 22:56:16.288 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28635, is has a dead item count of 0.
Aug 25, 2021 22:56:16.288 [0x7fda73342b38] Debug β Deleting media item 62400.
Aug 25, 2021 22:56:16.289 [0x7fda73342b38] Debug β Was connected to metadata item 28635, count is now 0.
Aug 25, 2021 22:56:16.290 [0x7fda73342b38] Debug β Destroying metadata item 28635 (The Hobbit: The Desolation Of Smaug: Stephen Fry)
Aug 25, 2021 22:56:16.372 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 551 deleted
Aug 25, 2021 22:56:16.372 [0x7fda73342b38] Debug β Deleting media item 62401.
Aug 25, 2021 22:56:16.373 [0x7fda73342b38] Debug β Was connected to metadata item 28636, count is now 2.
Aug 25, 2021 22:56:16.374 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28636, is has a dead item count of 0.
Aug 25, 2021 22:56:16.374 [0x7fda73342b38] Debug β Deleting media item 62402.
Aug 25, 2021 22:56:16.375 [0x7fda73342b38] Debug β Was connected to metadata item 28636, count is now 1.
Aug 25, 2021 22:56:16.376 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28636, is has a dead item count of 0.
Aug 25, 2021 22:56:16.376 [0x7fda73342b38] Debug β Deleting media item 62403.
Aug 25, 2021 22:56:16.377 [0x7fda73342b38] Debug β Was connected to metadata item 28636, count is now 0.
Aug 25, 2021 22:56:16.377 [0x7fda73342b38] Debug β Destroying metadata item 28636 (The Hobbit: The Desolation Of Smaug: This Is Our Fight)
Aug 25, 2021 22:56:16.459 [0x7fda733a1b38] Debug β [LibraryTimeline] Scanner activity on section -1: 0 added, 552 deleted
Aug 25, 2021 22:56:16.459 [0x7fda73342b38] Debug β Deleting media item 62404.
Aug 25, 2021 22:56:16.460 [0x7fda73342b38] Debug β Was connected to metadata item 28637, count is now 2.
Aug 25, 2021 22:56:16.460 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28637, is has a dead item count of 0.
Aug 25, 2021 22:56:16.460 [0x7fda73342b38] Debug β Deleting media item 62405.
Aug 25, 2021 22:56:16.461 [0x7fda73342b38] Debug β Was connected to metadata item 28637, count is now 1.
Aug 25, 2021 22:56:16.462 [0x7fda73342b38] Debug β Updating deletion state for metadata item 28637, is has a dead item count of 0.
Aug 25, 2021 22:56:16.462 [0x7fda73342b38] Debug β Deleting media item 62406.
Aug 25, 2021 22:56:16.463 [0x7fda73342b38] Debug β Was connected to metadata item 28637, count is now 0.
This (and more related entries β variants of βThe Hobbit: The Desolation of Smaugβ) kept repeating over and over again. Now I do have this movie in my library, and I suspect the problem is that I have two versions of it:
the_hobbit-the_desolation_of_smaug-extended_edition.mkv
the_hobbit-the_desolation_of_smaug.mkv
I removed these items from the filesystem, but no amount of rescanning the library would fix the problem. Plex just kept getting stuck spitting out those same log messages. I also tried deleting the whole Movies library, but it also just hung and could not be deleted.
The other movies it got stuck on while scanning were the only two movies that were in their own folders:
apollo_11/apollo_11.mkv
apollo_11/apollo_11_discovering_the_65mm-featurette.mkv
inside_out/Lava-short.mkv
inside_out/inside_out.mkv
I didnβt see any entries for these in the plex log, so I donβt think they were causing the same problem that the hobbit movie was, but these were the two other movies that the scanner seemed to get stuck on during the library upgrade (i.e. the scanning status box in the web ui would get stuck on these movies). I also removed these files from the filesystem, but a rescan never removed them (likely because the rescan was broken due to the issues with the Hobbit movie, which happened any time I tried to do a library scan).
I tried restoring the database from a week old backup, which didnβt help. I also downgraded the plex server to 1.24.0.4930. This didnβt help either.
Since I couldnβt delete the movies library, and I couldnβt find any other way to fix the issue, I poked around in the sqlite database, and I was able to manually remove the entry for βThe Hobbitβ:
[root@altair ~]# cd /var/lib/plex/Plex\ Media\ Server/Plug-in\ Support/Databases
[root@altair Databases]# /usr/lib/plexmediaserver/Plex\ SQLite com.plexapp.plugins.library.db
sqlite> .headers on
sqlite> select * from metadata_items where "original_title" like "%Desolation%";
id|library_section_id|parent_id|metadata_type|guid|media_item_count|title|title_sort|original_title|studio|rating|rating_count|tagline|summary|trivia|quotes|content_rating|content_rating_age|index|absolute_index|duration|user_thumb_url|user_art_url|user_banner_url|user_music_url|user_fields|tags_genre|tags_collection|tags_director|tags_writer|tags_star|originally_available_at|available_at|expires_at|refreshed_at|year|added_at|created_at|updated_at|deleted_at|tags_country|extra_data|hash|audience_rating|changed_at|resources_changed_at|remote
97|2||1|plex://movie/5d77689aebdf2200209c3571|1|The Hobbit: The Desolation of Smaug Extended Edition|Hobbit: The Desolation of Smaug Extended Edition|The Hobbit: The Desolation of Smaug|Warner Bros. Pictures|7.40000009536743||Beyond darkness... beyond desolation... lies the greatest danger of all.|The Dwarves, Bilbo and Gandalf have successfully escaped the Misty Mountains, and Bilbo has gained the One Ring. They all continue their journey to get their gold back from the Dragon, Smaug.|||PG-13||1||9660000|upload://posters/com.plexapp.agents.themoviedb_620dff734326de5f15e9140f07ef863bfad48f5b|upload://art/com.plexapp.agents.themoviedb_138d5fe9efd1124c199a8af8881d587de961e719|||||||||2013-12-02 00:00:00|||2021-07-14 03:00:41|2013|2015-04-17 20:13:56|2014-06-28 18:11:23|2021-07-14 03:00:41|||at%3AaudienceRatingImage=rottentomatoes%3A%2F%2Fimage%2Erating%2Eupright&at%3AratingImage=rottentomatoes%3A%2F%2Fimage%2Erating%2Eripe&ex%3AhasPremiumExtras=1&ex%3AhasPremiumPrimaryExtra=1&ex%3AprimaryExtraKey=%2Flibrary%2Fmetadata%2F323054&ma%3AchapterSource=media&pv%3AartBlurHash=LD9%3F%3Ahb%5E0gRQw0Iqay%24%25RQNHS%23%25K&pv%3AblurHashesChangedAt=47224115&pv%3AthumbBlurHash=T78%7CFdJV0%23%3D_I%3DNG9ZNGxZ9uf5of|637e2ef7a2043312d17c1ab40da33c8ed121782f|8.5|47224115|47224115|
sqlite> delete from metadata_items where id = 97;
sqlite> .exit
Much to my surprise and delight, this seemed to remove this entry from the library, and a library scan was then able to complete. I added back the apollo_11 and inside_out directories, and the two hobbit movie variants, and a library scan completed successfully!
This original (non-extended) edition of the hobbit was one of the earlier movies I added to plex (from probably 5 or 6 years ago). Maybe something got corrupted in the metadata over the years, or when I added the extended edition of this movie. This movie is kind of different in that the plex agent doesnβt have an extended edition of this movie (unlike the other two hobbit movies, which do have different extended editions in the metadata). So I need to split these two apart in Plex and edit the labels to identify which is which.
Anyway, this was a long and frustrating fix (probably took me about 4-6 hours to figure out). Hopefully someone else finds this useful!