Slow Query time - unable to scan or play media

I don’t still have the DB file from @jakehoms. But I’ll ping you if I come across other examples.

1 Like

Hi @Volts and @sa2000 . I’m sorry if I missed a comment - are you waiting on me to send something further?

I did send the earlier 6.4GB DB file to Volts via a PM, which helped me solve the issue as I noted above. That would be the DB file prior to any purging occurring.

If you need a DB post purging, I should be able to get that to you as well. I can tell you that, since the purging mentioned above, Plex has been working reliably (and the DB not getting insanely large), even after a few Plex package updates.

I am currently in the process of migrating my Plex environment to a Docker container so I don’t expect to have my old system around for much longer. It’s already not my active Plex server, but it is available if you need files from it. Happy to help where I can to assist the greater Plex community!

I would like the db before post purging but only if there is evidence of a high number of extras being added for a metadata id. So capturing the db before it gets very large but whilst starting to

I need to establish if the 2 million extras you got for that movie was due to a bug that has been addressed or if there is still a bug leading to this and to capture before we get anywhere near 2 million eg 1000 and together with some debug server logs covering a period before the db snapshot with LogNumFiles set high - eg 50

Do you still have that file, or an old enough backup?

I checked all my backups, but unfortunately I do not have that 6.4GB DB file any longer. I cleared out some extra backup data this past weekend so missed it by just a few days :(. Sorry, but if I can help with something else please let me know.

Suggest you do not purge any data from the database and if db starts to grow again and you notice similar issue building up - then get me the db and debug server logs zip with a LogNumFiles of 50

was the problem with specific movies ?
was sync being used?
Any third party plugins relating to trailers / extras

Has anybody seen any build up of extras since purging ? I still do not know if the cause has been fixed - the last example I have of it happening still was for extras added 15th October - the version of PMS that was running then was 1.24.4.5081-e362dc1ee

But I do not have any logs for the 15th October

Related forum topic Plex Crashes Every 3 Days at 3:30am Due to System “Out of Memory” Since PMS 1.24.4.5081 - Plex Media Server / NAS & Devices - Plex Forum

Nope.

But I only ever had a few extra extras myself, so I don’t think I’m a good reference.

I am having the identical problem to what is listed. Database size is currently over 3.6gb and will crash the server every 3 days. I am using QNap NAS which only allows access via SSH to run the commands. I have managed to run the first SQL command with the following results

count(metadata_item_id) | metadata_item_id
1049602 | 45323
50 | 34015
50 | 34810
50 | 34843
50 | 41103
50 | 41409
50 | 41896
46 | 48930
43 | 41648
42 | 48853
41 | 34164
41 | 83510
40 | 47767
39 | 47408
38 | 47335
37 | 41797
37 | 80017
36 | 35103
36 | 47215
35 | 42995

I have manually spaced for easier reading. I do need to purge the offending records particularly the first one but ssh doesn’t seem to want to run the command to purge the files. I have the sql.txt ready it just doesn’t seem to run command with the error message -sh: Plex Media Server: command not found displayed. I was in the .qpkg app folder at the time so could run without the program path location and did adjust the paths to the correct database location but won’t run.
Is there a way to get your SQL script to work on an NAS using ssh?

Can you share a screenshot of the command you ran and the output?

I’m not a qnap expert, but I’m guessing the issue is with the path or escaping/quoting the command line.

Hi
Thanks for the reply, the following is the command I used along with a screenshot of the output, I was already in the package folder for Plex before starting so didn’t need the path.

Plex\ Media\ Server --sqlite /share/CACHEDEV1_DATA/PlexData/Plex \Med


ia\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db < sql.txt

If you have not yet deleted the metadata_relations entries - could you run this query to see the date of the last addition of the duplicate extras

select metadata_item_id, related_metadata_item_id, created_at from metadata_relations Where metadata_item_id = '45323' ORDER BY created_at desc LIMIT 10 ;

would like to know if it is recent and what version of Plex Media Server you were running on at that time and what the movie guid and title are - may not be easy for you to let me have the 3Gb database !

If it is recent - then need to be on the lookout for new additions and capture logs and db again soon after the new additions are made.

Hi
I have run that query with the following results

metadata_item_id | related_metadata_item_id | created_at
45323 | 1138365 | 2021-10-24 11:18:19
45323 | 1138366 | 2021-10-24 11:18:19
45323 | 1138367 | 2021-10-24 11:18:19
45323 | 1138368 | 2021-10-24 11:18:19
45323 | 1138369 | 2021-10-24 11:18:19
45323 | 1138370 | 2021-10-24 11:18:19
45323 | 1138371 | 2021-10-24 11:18:19
45323 | 1138372 | 2021-10-24 11:18:19
45323 | 1138373 | 2021-10-24 11:18:19
45323 | 1138374 | 2021-10-24 11:18:19

I’m currently on V1.24.5 (server) which was installed on the 3rd Nov, I’ve been trying to update when altered so on the date listed it is likely to be the previous version. I have looked at the files uploaded at the time and were a couple of series so shouldn’t have many extras associated with it.
It is worth noting though that I have only been a premium member for the last few months so it might be possible it was downloading extras for an old file but without a title or filename I can’t be 100% sure.

Thank you - So the additions stopped after 24th October 11:18

It is very possible that the cause of the problem has got fixed

It is either that or we crashed every time we were trying to do it (because of the number of extras we reached)

What I need are server logs when they are getting added - like in this case it would be the logs covering 24th October around 11am

This query will identify the movie

select id, title, guid, refreshed_at from metadata_items Where id = '45323';

(Please give @sa2000 any additional information requested before doing this cleanup - don’t want to remove any necessary diagnostic evidence!)

This would need to include a ./ at the beginning of the Command Line. Most unix-like operating systems don’t search the Current Working Directory for executables by default; ./ is the current directory.

There’s also a \ out of order in the path to the database file. .../Plex \Media\ Server/... needs to be .../Plex\ Media\ Server/....

Plex has added a Plex SQLite utility that can be called directly. So I think this might be the command:

./Plex\ SQLite /share/CACHEDEV1_DATA/PlexData/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db < sql.txt

I have just tried your suggestion which seems to be processing for a few seconds before displaying the error message “Database or disk is full”. Could this possibly be a corrupt database, it seems to be working fine though.

SQLite use /tmp for storage
On a QNAP, that’s RAM disk :frowning:

Suggest you copy database to a workstation, and run it from there, and afterwards, copy it back again

:mindblown:

Right
I have copied the db file to my desktop and ran the following line of code at the command prompt

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

all I get is the following output

Error: near line 3: no such collation sequence: icu_root
Error: near line 43: no such collation sequence: icu_root

I thought it might be a database corruption issue so tried the PRAGMA integrity_check command with the same error occurring.

Could there be a access rights issue with the file which is preventing it being edited?

You are using the wrong/old set of instructions.
https://support.plex.tv/articles/repair-a-corrupted-database/