Library wont display

For a while now plex has been stalling in displaying my library even when filters aren’t applied. It fails with a generic error saying something about an unexpected error has occurred. I see lots of slow transactions in the log, and errors about unknown metadata for a folder, but nothing leading me to a fix. I’ve rolled back versions and used DB repair to no avail.

May I see the server DEBUG log files?

May I also see a ls -la listing of the Databases directory ?

This was in it:

Jul 07, 2025 14:03:31.095 [139962207849272] ERROR - [Req#133c80] SQLITE3:0x208, 1, no such column: media_items.begins_at in "select metadata_items.id from metadata_items   join metadata_item
s as parents on parents.id=metadata_items.parent_id  join metadata_items as grandparents on grandparents.id=parents.parent_id  where metadata_items.library_section_id in (1) and (metadata_it
ems.metadata_type=4 and metadata_items.id in (select taggings.metadata_item_id from taggings join tags on tags.id=taggings.tag_id where tags.id=-1))  order by  media_items.begins_at asc, met
adata_items.id asc, media_items.width desc, metadata_items.originally_available_at asc, media_parts.id asc"                                                                                   Jul 07, 2025 14:03:31.095 [139962207849272] ERROR - Got exception from request handler: sqlite3_statement_backend::prepare: no such column: media_items.begins_at for SQL: select metadata_ite
ms.id from metadata_items   join metadata_items as parents on parents.id=metadata_items.parent_id  join metadata_items as grandparents on grandparents.id=parents.parent_id  where metadata_it
ems.library_section_id in (1) and (metadata_items.metadata_type=4 and metadata_items.id in (select taggings.metadata_item_id from taggings join tags on tags.id=taggings.tag_id where tags.id=-1))  order by  media_items.begins_at asc, metadata_items.id asc, media_items.width desc, metadata_items.originally_available_at asc, media_parts.id asc

PM sent.

@Gloppie

Please get into the Databases directory under /var/lib/plexmediaserver
and run the following command

time /usr/lib/plexmediaserver/Plex\ SQLite com.plexapp.plugins.library.db 'select count(*) from metadata_items;'

You should get output like this:

25898

real	0m0.012s
user	0m0.009s
sys	0m0.003s
[chuck@lizum databases.2025.05.17.2033]$

Your logs are showing me a terribly fragmented and likely damaged database.
It’s so bad that PMS cannot function.

Jul 07, 2025 15:12:09.286 [139962532088632] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/Database/SqliteDB.h:100): 0.120000 seconds
Jul 07, 2025 15:12:09.296 [139962532088632] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/Database/SqliteDB.h:100): 0.130000 seconds
Jul 07, 2025 15:12:09.301 [139962532088632] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MetadataItem.cpp:7625): 0.410000 seconds
Jul 07, 2025 15:12:09.321 [139962532088632] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MetadataItem.cpp:7625): 0.140000 seconds
Jul 07, 2025 15:12:09.334 [139962537290552] WARN - SLOW QUERY: It took 700.000000 ms to retrieve 1 items.
Jul 07, 2025 15:12:09.342 [139962532088632] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MetadataItem.cpp:1095): 0.330000 seconds
Jul 07, 2025 15:12:09.347 [139962543622968] WARN - SLOW QUERY: It took 690.000000 ms to retrieve 1 items.
Jul 07, 2025 15:12:09.361 [139962231511864] WARN - SLOW QUERY: It took 510.000000 ms to retrieve 0 items.
Jul 07, 2025 15:12:09.414 [139962127809336] WARN - SLOW QUERY: It took 610.000000 ms to retrieve 0 items.
Jul 07, 2025 15:12:09.439 [139962532088632] WARN - SLOW QUERY: It took 820.000000 ms to retrieve 1 items.
Jul 07, 2025 15:12:09.441 [139962543622968] WARN - SLOW QUERY: It took 770.000000 ms to retrieve 1 items.
Jul 07, 2025 15:12:09.443 [139962509830968] WARN - [Req#2306ab] Invalid library metadata ID plex://show/5fc69841c2d465002df6f715 passed.

How many different versions have you rolled back and forward to ?
( How many switches ?)

t(*) from metadata_items;'
1

real    0m0.060s
user    0m0.020s
sys     0m0.040s

You’ve said DBRepair is of no help?

84,661 items is not a large database.

Judging by the size of the blobs DB, You have a fair amount of music ?

What type of device is PMS installed on? (SATA , native or USB connected ?)

What’s the filesystem it’s formatted with ?

DBRepair was of no help. The main / is a RAID0 of four NVME’s in a highpoint PCIE card using ZFS. This box is a beast and really shouldn’t be hanging like it is.

What’s the zfs record size ?

(DBREPAIR_PAGESIZE variable is used to tune the DB to match the host)

128K is the current record size

Have you attempted a DB ‘auto’ optimization with

export DBREPAIR_PAGESIZE=65536

?

no I’ve not tried that. What should I go with first?

Go with DBREPAIR_PAGESIZE=65536
(what I’ve programmed as max … but will show you / will customize for you - how to st to 131072

It will still take time to read it but the writing will be multiples of ZFS record sizes

After that, the DB will be tuned for the ZFS record size.

Setting Plex SQLite page size (65536)

Yes, that’s what it will do

Still not a fix.

I have a TrueNAS box. (not setup PMS on it yet)

– I will setup apps (docker registry) and then load PMS

I have a 287K media item library to load on it.

Edit: Test instance on TrueNAS Community Edition (Scale) now loading.
cpu: i7-8809 (older kabylake)
storage: nvme 1TB Samsung 970 pro

@Gloppie

My machine finished setting up the TV shows.

CPU: i7-8809g ( NUC8-i7-HVK ) @ 3.1 Ghz

Platform:    Generic 
Edition:     Community 
Version:     25.04.1
Hostname:    truenas 
Uptime:      36 days 11 hours 55 minutes as of 12:13 

SSD:

Disk Size:      931.51 GiB
Transfer Mode:  Auto
Serial:         ---radacted---
Model:          Samsung SSD 980 PRO 1TB
Type:           SSD
HDD Standby:    ALWAYS ON
Description:    N/A

Single VDEV, Single PDEV

Plex container. 1.41.8.9834-071366d65

root@truenas:/home/truenas_admin# docker exec -it ix-plex-plex-1 bash
root@truenas:/# cd /config/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/
root@truenas:~/Library/Application Support/Plex Media Server/Plug-in Support/Databases# /usr/lib/plexmediaserver/Plex\ SQLite  com.plexapp.plugins.library.db
SQLite version 3.39.4 2022-09-29 15:55:41
Enter ".help" for usage hints.
sqlite> select count(*) from metadata_items;
121649
sqlite> 

Database record size – Default.

There are no SLOW QUERY entries in the logs.

Plex web does not have response issues (“Something went wrong”) unless I’m trying to load the entire page while refreshing all the metadata.

What is the per-thread speed of that machine?

Multithread Rating

8516

Single Thread Rating

2378

So whats your best advise on how to recover without loosing watched history, and such?

In your account, do you have “Sync my watch status and ratings” enabled?