Database locked

Server Version#: 1.25.1.5286
Player Version#:
I am running Plex on ubuntu 20.04.3, Intel Core I5-10400, 256GB SSD, 16GB RAM, media directory are on a readnas, shares mounted via smb.

I am unable to add new item, look in the logs, I get

exception thrown during analysis: Cannot begin transaction. database is locked

What I did I restored the last backup of the two database files, same issue.

What else can I do to unlock the database

@AViering

  1. Stop Plex
  2. On the command line, navigate down into /var/lib/plexmediaserver until you see “Logs”
  3. Create a tar.gz of the Logs directory
  4. Post that tar.gz here

@ChuckPa ok, I did
log05112021.tar.gz (2.8 MB)

@AViering

Thanks for the logs.

PMS is upgrading / updating all your metadata

I don’t know if you can hear the HDDs but I’m sure they’re busy.

Given what I see here. “Let it run”.

it has a lot of work to do.

Dec 05, 2021 12:42:22.374 [0x7f559c57bb38] DEBUG - Was connected to metadata item 60187, count is now 1.
Dec 05, 2021 12:42:22.374 [0x7f559c57bb38] DEBUG - Updating deletion state for metadata item 60187, is has a dead item count of 0.
Dec 05, 2021 12:42:22.374 [0x7f559c57bb38] DEBUG - Deleting media item 70418.
Dec 05, 2021 12:42:22.375 [0x7f559c57bb38] DEBUG - Was connected to metadata item 60187, count is now 0.
Dec 05, 2021 12:42:22.375 [0x7f559c57bb38] DEBUG - Destroying metadata item 60187 (Home Alone 25th Anniversary (Fathom Events Trailer))
Dec 05, 2021 12:42:22.512 [0x7f559c57bb38] WARN - Held transaction for too long (../Library/MetadataItem.cpp:906): 0.140000 seconds
Dec 05, 2021 12:42:22.513 [0x7f559ab5cb38] DEBUG - [LibraryTimeline] Scanner activity on section -1: 0 added, 531 deleted
Dec 05, 2021 12:42:22.513 [0x7f559c57bb38] WARN - Held transaction for too long (../Library/MediaItem.cpp:813): 0.140000 seconds
Dec 05, 2021 12:42:22.513 [0x7f559c57bb38] DEBUG - Deleting media item 70419.
Dec 05, 2021 12:42:22.513 [0x7f559c57bb38] DEBUG - Was connected to metadata item 60188, count is now 2.
Dec 05, 2021 12:42:22.514 [0x7f559c57bb38] DEBUG - Updating deletion state for metadata item 60188, is has a dead item count of 0.
Dec 05, 2021 12:42:22.514 [0x7f559c57bb38] DEBUG - Deleting media item 70420.
Dec 05, 2021 12:42:22.514 [0x7f559c57bb38] DEBUG - Was connected to metadata item 60188, count is now 1.
Dec 05, 2021 12:42:22.515 [0x7f559c57bb38] DEBUG - Updating deletion state for metadata item 60188, is has a dead item count of 0.
Dec 05, 2021 12:42:22.515 [0x7f559c57bb38] DEBUG - Deleting media item 70421.
Dec 05, 2021 12:42:22.516 [0x7f559c57bb38] DEBUG - Was connected to metadata item 60188, count is now 0.
Dec 05, 2021 12:42:22.516 [0x7f559c57bb38] DEBUG - Destroying metadata item 60188 (Home Alone: Family Disappear)
Dec 05, 2021 12:42:22.653 [0x7f559c57bb38] WARN - Held transaction for too long (../Library/MetadataItem.cpp:906): 0.140000 seconds
Dec 05, 2021 12:42:22.653 [0x7f559ab5cb38] DEBUG - [LibraryTimeline] Scanner activity on section -1: 0 added, 532 deleted
Dec 05, 2021 12:42:22.653 [0x7f559c57bb38] WARN - Held transaction for too long (../Library/MediaItem.cpp:813): 0.140000 seconds
Dec 05, 2021 12:42:22.653 [0x7f559c57bb38] DEBUG - Deleting media item 70422.
Dec 05, 2021 12:42:22.654 [0x7f559c57bb38] DEBUG - Was connected to metadata item 60189, count is now 0.

Those short locked / held too long messages don’t matter as long as they clear themselves in the next second or two.

@ [ChuckPa]thanks, I am sorry PMS is not upgrading / updating, nothing happens. I added some new films to the movie share. I will wait the next 24h if something happens, and will be back.
Andreas

@AViering

Would you please download the logs ZIP file and attach it here for me?

@ChuckPa thanks, just some minutes ago
log110620212045.tar.gz (10.6 MB)

@AViering

Regrettably,

Searching your logs for “busy” or “locked” has no results.

Are you certain it was a database lock or was PMS busy upgrading to this version?

@ChuckPa yes, yesterday, cpu usage was 100%, PMS was unusable, pms process needed to be killed. The match logs showed database locked. I started service again, tried manual search, same behavior. Now PMS is streaming but not updating the database. Before starting manual search again, with danger of corrupting database, I try to find the problem.

Sorry, did log in with a account of my son, sorry for confusion.

The manual logs are independent of the account used – unless you did that from a different server instance?

@ChuckPa I ment login (david_viering_me_com is the forum account of my handicapped son) in the forum. I do have only on server instance running.

That’s OK… I understand completely.

The next time the CPU shows as 100% ,

Restart Plex and grab the logs.

I’ll be able to see what’s happening.

@ChuckPa I manually started adding new data to films. PMS is still processing. CPU is about 10% PMS is answering very slow.
log1207211655.tar.gz (5.2 MB)

@AViering

Thank you for that log.

Where is the database ? Is it on a USB drive?

How large is the DB (physical size) ?
when is the last time it was manually optimized ?

10% CPU on a quad core which supports hyperthreading (8 total),
means it’s 10% of an indicated 12.5% if a full core.

The behavior is one physically slow DB response.

@ChuckPa the database is on the internal ssd.

The library.db is 3.54 GB.

The db was never manually optimezed, it was always done by tasks in the setttings.

1h later PMS uses 60% CPU and does not respond

3.54 GB is HUGE. That DB is in trouble – unless you have about 750,000 items indexed and automatically cross referenced to extras.

Before I go ask for help.

  1. How many media items (movies, episodes, songs , photos, other videos) do you have indexed ?

  2. When is the last time –

  • trash emptied (marks dead records for removal from the DB)
  • bundles cleaned – deletes records from the DB file and stray .bundles of metadata
  • Optimized db (as the last step)

I know you said it runs automatic but unless you have either

  • an insane amount of media
  • are running on the version of PMS before they fixed that problem.

I’m having trouble figuring out how it could remain so large.

Have you ever performed a manual export of the DB to a SQL file then regenerated the DB from that source file?

@ChuckPa

My media has grown for years, there are 2700 movies, 37000 songs and 1100 TV shows, no pictures.
The db was build from ground 2 month ago.

When I started with PMS, PMS did the work on my nas, after some years I decided to install a standalone server for PMS. Moving the db from my nas to the ubuntu server did not work so I decided to build it new.

A lot of manual work, but finally everything was fine.

So there was no need to do some manual with the db, or export to SQL.

@AViering

I’m working with Engineer right now.

Would it be possible to get a copy of your DB ?

(I’ll send you a PM so you can provide a link for downloading)

@ChuckPa thanks, for sure, I am happy to get help