Library scan is replacing all metadata, rebuilding entire library database

Sometime in the past few weeks the behavior of Scan Library Files has changed. I’m not sure if this intended or if it’s a bug, but any time I add new media and then run Scan Library Files (Movies or TV) it will rescan everything that’s already present and download and replace all of the metadata for everything in the library. This is getting particularly annoying since any shows or movies where I’ve changed the poster or other data will have it set back to the default. The scan also takes longer than it did and many shows/movies become unavailable while the scan runs.

Previously when I scanned the library for new media using Scan Library Files, none of the existing items were changed or altered from the scan.

Is this an expected behavior change? How can I get it back to ONLY scanning and adding metadata for new items?

Edit: Some additional info…

Running server version 1.13.8.5395 on FreeBSD.

Edit: SOLVED 2/9/19 - I finally tracked down what was causing this problem. It seems that I’d stumbled onto some odd behavior based upon how my TV library folder was structured.

I’d wanted to create two libraries for TV shows, one of which contained all of my shows and another that were shows I didn’t mind the kids watching, which I called Public. To do this, I structured my TV folder in a nested fashion, with “TV Shows” containing subfolders with the shows only for the parents to see and a subfolder called Public which were meant for clean shows. It looked like this:

/media/TV Shows
----Show 1
----Show 2
----Show 3
d—Public
------Show 4
------Show 5
------Show 6

I then created a library ‘TV Shows’ which only linked to the ‘Public folder’ and another one, ‘TV Shows - All’ which linked the parent ‘TV Shows’ folder. The expectation was that it would display all shows directly within the ‘TV Shows’ folder along with what was contained in the ‘Public’ subfolder. They looked like this:

TV Shows - All
linked to: ‘/media/TV Shows’

TV Shows
linked to: ‘/media/TV Shows/Public’

The problem I had was that with the ‘TV Shows - All’ library, it didn’t actually include the shows within Public. It was at this point that I realized I could just add multiple folders to a library, so I added ‘/media/TV Shows’ and ‘media/TV Shows/Public’, which successfully included all of the shows. Now, that library looked like this:

TV Shows - All
linked to: ‘/media/TV Shows’
linked to: ‘/media/TV Shows/Public’

It was this library, ‘TV Shows - All’, in this state, which was having the problem in my OP. Every time I’d scan for files again, it would reset all customized metadata and settings.

This morning, I was revisiting this issue and looking at library settings and scan logs and realized this was the only library with a weird nested folder thing going on. It dawned on me that perhaps this wasn’t really a supported structure since libraries were clearly designed to link to multiple disparate folders anyway.

To confirm this, I removed the ‘Public’ folder from the library and rescanned. It did not reset the metadata for the remaining shows, even after scanning a few times. I then moved the Public folder out and directly under /media as ‘/media/TV Shows - Public’. The folder structure now looks like this:

/media/TV Shows
—Show 1
—Show 2
—Show 3
/media/TV Shows-Public
—Show 4
—Show 5
—Show 6

I then added the newly moved Public folder back to the TV Shows library and rescanned, which now looks like this:

TV Shows - All
linked to: ‘/media/TV Shows’
linked to ‘/media/TV Shows - Public’

Once everything was populated, I made a few manual changes to the library (changed a few posters, set Seinfeld to DVD order, etc) and then rescanned a few times. Now the behavior is as expected. Any existing media retains its custom settings and no metadata resets.

Please post the Plex XML info of a movie which has been affected by this.

Here’s one example below of a show that was set back to defaults due to a library scan. Basically, all I did was add a few episodes to another show and then scanned the library (something I’ve done more times than I can count). When I clicked Scan Library Files, it began the scan and literally everything disappeared from the TV library and then slowly populated back as the scan ran as though it was rebuilding the entire library database. When it was done, this show and a few others that I’d changed the poster for had been replaced. Other shows, which had no episodes added or removed, disappeared as I mentioned above during the scan, then first populated with only basic info (No episode titles, descriptions, or images) and then finally populated as the scan completed.

As far as I can tell, it’s rebuilding the entire library instead of just finding the changes.

<MediaContainer size=“1” allowSync=“1” identifier=“com.plexapp.plugins.library” librarySectionID=“2” librarySectionTitle=“TV Shows” librarySectionUUID=“8a31bfe4-79fd-46e2-a2e2-5061a1250353” mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion=“1537526835”>

<Video ratingKey=“18757” key="/library/metadata/18757" skipParent=“1” parentRatingKey=“18756” grandparentRatingKey=“18755” guid=“com.plexapp.agents.thetvdb://85040/1/1?lang=en” librarySectionTitle=“TV Shows” librarySectionID=“2” librarySectionKey="/library/sections/2" type=“episode” title=“Pilot” grandparentKey="/library/metadata/18755"parentKey="/library/metadata/18756" grandparentTitle=“Caprica” parentTitle=“Season 1” contentRating=“TV-14” summary=“58 years before Battlestar Galactica, an astonishing breakthrough is taking shape on the planet Caprica. The creator of a failing urban combat robot project tries to bring a virtual copy of his dead daughter into the real world, using a stolen processor, his combat chassis and her code. He thus creates the Cybernetic Life form Node or CYLON. The rapidly evolving spheres of human and mechanical engineering have collided, along with the fates of two families. Joined by tragedy in an explosive instant of terror, two rival clans led by powerful patriarchs, Joseph Adama (Esai Morales) and Daniel Greystone (Eric Stoltz) duel in an era of questionable ethics, corporate machinations and unbridled personal ambition as the final war for humanity looms.” index=“1” parentIndex=“1” rating=“7.8” year=“2009” thumb="/library/metadata/18757/thumb/1539116136" art="/library/metadata/18755/art/1539116429"parentThumb="/library/metadata/18756/thumb/1539115467" grandparentThumb="/library/metadata/18755/thumb/1539116429" grandparentArt="/library/metadata/18755/art/1539116429" grandparentTheme="/library/metadata/18755/theme/1539116429" duration=“5540076” originallyAvailableAt=“2009-04-21” addedAt=“1539114834” updatedAt=“1539116136”>

<Media videoResolution=“sd” id=“26425” duration=“5540076” bitrate=“1059” width=“624” height=“352” aspectRatio=“1.78” audioChannels=“2” audioCodec=“mp3” videoCodec=“mpeg4” container=“avi” videoFrameRate=“24p” videoProfile=“advanced simple”>

<Part accessible=“1” exists=“1” id=“26524” key="/library/parts/26524/1365358680/file.avi" duration=“5540076” file="/var/db/plexdata/Plex Media Server/media/TV/Public/Caprica/Season 1/Caprica.S01E01.Pilot.avi" size=“733581312” container=“avi” videoProfile=“advanced simple”>

<Stream id=“44616” streamType=“1” codec=“mpeg4” index=“0” bitrate=“913” bitDepth=“8” chromaLocation=“left” chromaSubsampling=“4:2:0” frameRate=“23.976” height=“352” level=“5” profile=“advanced simple” refFrames=“1” width=“624” displayTitle=“SD (MPEG4)”/>

<Stream id=“44617” streamType=“2” selected=“1” codec=“mp3” index=“1” channels=“2” bitrate=“133” audioChannelLayout=“stereo” samplingRate=“48000” streamIdentifier=“1” displayTitle=“Unknown (MP3 Stereo)”/>

</Part>

</Media>

<Director id=“7233” filter=“director=7233” tag=“Jeffrey Reiner”/>

<Writer id=“7232” filter=“writer=7232” tag=“Remi Aubuchon”/>

<Writer id=“7161” filter=“writer=7161” tag=“Ronald D. Moore”/>

<Extras size=“0”> </Extras>

</Video>

</MediaContainer>

The addedAt timestamp of this episode says that it is only in the library since
GMT : Tuesday, 9. October 2018 19:53:54
I think the file is there a little longer already, right?

So, what happened is very likely this:
Your media storage is not reliable. It is either on a NAS which powers down its drives ( and spinning them back up takes too long when Plex requests a file or even a simple directory.)
Or media storage is on external drves with connection troubles or even on Cloud-based storage.
If a request from Plex is not fulfilled within a reasonable time, Plex will mark the file or folder in question as ‘unavailable’.
Now there is a preference in Plex under
Settings - Server - Library
called ‘empty trash automatically’.
If this is activated, all those ‘unavailable’ media items are kicked out of the Plex library at once, and with them all your carefully edited metadata.
If you now request a library update, the files are found again and are added “as new” - with all meta data at the default value.
So: never activate this preference if your media storage is not internal hard drives within the Plex server device itself.

Hmm, OK, that probably doesn’t really fit my situation then. I’m running FreeNAS with 8x WD Red Pro drives in a Raid configuration and Plex is running locally on that server. This server has been running fine for a few years and I’ve never encountered this sort of problem. That timestamp looks about around the time I ran the library scan, but it was definitely accessible before I ran the scan.

Also, while I posted this XML as a sample, it’s important to note that EVERY single show was removed and re-added during the library scan. I doubt every single file was unavailable and removed. Also, I’ve not encountered any of these files becoming unavailable when trying to view them.

There’s got to be another explanation here.

I’ll go ahead though and disable the “empty trash automatically” setting just to see if it makes a difference and report back.

Yeah, same thing. I disabled ‘empty trash automatically’ and it still resets any custom poster changes and removes/re-adds all episode or movie information, graphics, etc while it scans. I did a few subsequent library scans one right after another (surely not enough time for my library files to somehow become unavailable), but it exhibits the exact same behavior each time. Definitely some sort of buggy behavior here.

Are there any other logs or other information I can examine or provide to try and track this down?

https://support.plex.tv/articles/200250417-plex-media-server-log-files/

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