Deleting a file from the filesystem won't reflect in Plex library

Recently, my Plex install has been acting up.

First thing I noticed is that the server was acting a little sluggish. Manually scanning libraries takes a bit longer than it used to. Manually updating file status, such as marking something unwatched/watched takes a long time and sometimes doesn’t work. Browsing around the local server also takes a long time, sometimes get the circle cursor on a page without it loading up the content.

Secondly, leaving a page open browsing to a library will sometimes generate an error: “There was an unexpected error loading this library Please visit our forums if you continue to experience problems” that is fixed by clicking the refresh button on the browser.

The next thing I’d noticed is that when I tried to look at the Settings tab, it gave “Server settings are unavailable.” (I looked at this thread: https://forums.plex.tv/discussion/170396/server-settings-are-unavailable/p5 and removing the Subzero.bundle directory and reinstalling the plug-in fixed that.)

And the newest behavior I’ve noticed is that direct removal of a file from the filesystem will not reflect/update in the Plex library. The entry will remain and if you use “Get Info” on the entry, it will be flagged “Unavailable” instead of just removing the entry upon automatic/manual scans. It used to remove the entry from the Plex library if the actual file went missing. Now I have to manually delete the entries.

Looking at the Status Alerts section, whenever the server scans the library, it lists any missing files as “an item” in the logs.

Any advice how to fix it so scans will automatically delete entries of missing files? Also, any advice on the sluggishness? Etc.

  1. activate debug logging (not ‘verbose’!)
  2. quit Plex Server
  3. wait 1 minute
  4. start Plex Server
  5. wait 5 minutes
  6. fetch log files and attach them here

Or inspect them yourself. Take a look at the Plex Media Server.log file and seek for messages about database corrupt or malformed.
If you find these, you may have to repair your database.
Depending on your used version of Plex Server, the instructions for repairing the database differ slightly.
Please report back if you find any damage.

Hi! Thank you for the response. I went ahead and did as you advised. I also looked through the PMS logs, but did not find any instances of the words corrupt or malformed.

Before restarting Plex, I stumbled across another new behavior. Before I was able to manually delete the errant entries, but now when I try it, I get an error that said something like: “There was an unexpected error while deleting files.” Restarting the server seems to have fixed that for now.

Also, I was curious, other than manually killing processes, do you know if there is a way to shut down or restart Plex? Like a button to click on the web interface? If not, why the heck haven’t the devs added one? :slight_smile:

Stopping/closing the server is done with its task tray icon.

You can make extra sure and use the Windows Task Manager (CTRL+Shift+Esc) to shutdown any processes with ‘plex’ and ‘Python’ in their name.

What type of drive is D:?
Is is nearly full?
I hope it is a local/internal drive.

Did you instruct your anti virus software to stay out of D:\Local\PlexData ? If not, do it now.

Disable IPv6 support in Plex under
Settings - Server - Network - ‘Show Adanced’

Clean out Plex Plugins you are no longer using or which are no longer working. The less you have, the better.

If you are confident on the command line, I’d still recommend you to perform the database repair procedure - but only after performing/answering all of the above.

Ah, I see it. Thanks!

D: is a standard SATA internal HDD. It currently has about 1TB free space.

Added an exception to D:\Local\PlexData in my AV.

Disabled IPv6 support.

Alright. Uninstalled all Plex Plugins. I installed a bunch thinking I’d check them out/use them, but it turns out, I just watch the media that’s stored on my server.

Doing the stuff you suggested didn’t fix the problem.

Trying to visit that link generates the following page:
Oops, you don’t have access!
This area is restricted and requires special permission to access (such as being a Plex Pass subscriber or member of one of our app betas). If you believe your account is supposed to already have access visit https://forums.plex.tv/sso to re-sync your permissions.

Sorry, my mistake:

The following is an extended version of the repair instructions
https://support.plex.tv/articles/201100678-repair-a-corrupt-database/
Refer to this for download sources of the sqlite3 tool and the location of the database files.

#Shut down Plex Server before doing any of the below:

copy these 3 files out to a safe place (outside of Plex’s data), just in case you want to revert the procedure:

com.plexapp.plugins.library.db-shm
com.plexapp.plugins.library.db-wal
com.plexapp.plugins.library.db.original
sqlite3 com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"

sqlite3 com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"

It is of utmost importance, that the above commands are copied exactly as written, because they alter the database directly.

Now run the integrity check

sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"

And then attempt repair
export the DB to SQL file:

sqlite3 com.plexapp.plugins.library.db .dump > dump.sql 

Now rename the original, corrupted DB file
Linux/Mac: mv com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original
Windows: rename com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original

reimport the SQL dump back into a new DB file:

sqlite3 com.plexapp.plugins.library.db < dump.sql

Run another check to establish if repair was successful

sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"

Afterwards, start Plex server and leave it at least a few minutes alone.
It has to create several index tables during this time.
Depending on the size of your media collection this could take even longer.

Keep an eye on the disk activity in your server machine and only start using Plex when activity has died down.

No problem.

I ran the repair as you’ve recommended above. I will let you know the results after some more testing.

Thanks!

Okay, I went ahead and checked and it still has the behavior of maintaining old, dead entries. :frowning:

Edit your library where these items appear in.

On the ‘Add Folders’ tab, are there several folder paths?
If so, is one of these

  • not accessible to the Plex server
  • not existent anymore
  • completely empty
  • overlapping with a path that is already listed

?

Hi!

Each library has multiple folder paths.

However, all are still accessible (Plex can see when new stuff goes into any of them, just doesn’t remove entries anymore when stuff is deleted.)
Each path still exists.
None of them are empty or even close to being empty.
None of the paths are overlapping.

Is any of these paths a network share or a NAS?
Are you running Plex server as a Windows system service?

None of the paths are networked or NAS. They are all internal SATA drives connected directly to the motherboard’s SATA ports/controller.

I am not running Plex as a Windows system service, unless the update service that the installer created counts.

Hmm. Still having this behavior. Might this have been a change during a hotfix?

I have never asked you above if you actually tried to empty the library trash.
Have you?

https://support.plex.tv/articles/200392106-library-actions/

I have not, however, I did this after you mentioned it and it didn’t make any difference to the behavior.

Also, just to be clear, I am manually moving the files from one location to another in the filesystem using File Explorer. I am not deleting files from Plex using its UI. The weird thing is Plex used to handle this just fine.

The logs when Plex is doing a scan of the library with files that have been moved elsewhere looks like:
2:51pm Downloading metadata for an item
2:51pm Finished processing an item
2:51pm Downloading metadata for an item
2:51pm Finished processing an item

Whereas when the files are around, it lists the actual file instead of “an item…”

Emptying library trash is supposed to remove those items which have been marked as ‘unavailable’ from the library.
Are you saying those ‘unavailable’ items are staying in there?

Why are you moving files, btw?
Are you doing this regularly or is this a bigger file reorganization?

Yeah, I can try to empty the trash again since I just moved more files.

Ok, so it appears that emptying the trash a few times eventually got rid of some entries. I had to run an additional scan and re-emptied the trash again which got rid of other entries as well. The first time I tried that, it did not get rid of the unavailable item entries, but I think it is doing what I want.

I move files from a library of new items that are unwatched to another library that archives watched items in small batches. It is fairly regular depending on how much of the media I end up watching.

It is kind of weird that I didn’t have to do this in the past. I haven’t changed settings between when it worked and when it stopped working, but I’m guessing that telling the server to empty the trash regularly might fix my problem.

Now if I can only get the watched library to automatically be marked “watched” automatically and perhaps not show up in my searches when I’m looking for new media. :slight_smile:

There is a preference under Settings - Server - Library - ‘Empty trash automatically’
(Or similar wording)

But I recommend it to be activated only with internal media storage.

Thanks for the information. I noticed that option earlier but didn’t touch it/think much of it. I have turned it on.

Thus far all my media storage is internal, so that’s covered. :slight_smile: