Can't update library. Error: std::bad_cast

Server Version#: 1.29.2.6364
Player Version#: 4.110.1

So recently I’m getting this error and can’t update my libraries.
LibraryUpdater: exception updating libraries; pausing updates briefly before retrying: std::bad_cast

This started when I tried to add a large library to see if I could create a library of all sub-genres combined (Movies/Anime/Documentary/etc), then deleted it because it didn’t seem to work. All my libraries still work. It just won’t scan or make any file updates.

I may have to restore from backup.

Jul 15, 2023 11:16:34.290 [0x7fbce59d3b38] Warning — [Req#8ba7] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:34.290 [0x7fbce59d3b38] Warning — [Req#8ba7] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:34.404 [0x7fbce5bd6b38] Warning — [Req#8cde] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:34.404 [0x7fbce5bd6b38] Warning — [Req#8cde] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:34.726 [0x7fbce391eb38] Warning — [Req#8d01] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:34.726 [0x7fbce391eb38] Warning — [Req#8d01] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:36.501 [0x7fbce48e2b38] Error — LibraryUpdater: exception updating libraries; pausing updates briefly before retrying: std::bad_cast
Jul 15, 2023 11:16:36.580 [0x7fbce391eb38] Warning — [Req#8cca] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:36.580 [0x7fbce391eb38] Warning — [Req#8cca] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:41.580 [0x7fbce7a4ab38] Warning — [Req#90c1] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:41.580 [0x7fbce7a4ab38] Warning — [Req#90c1] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:46.583 [0x7fbce391eb38] Warning — [Req#919c] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:16:46.583 [0x7fbce391eb38] Warning — [Req#919c] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:17:06.502 [0x7fbce48e2b38] Error — LibraryUpdater: exception updating libraries; pausing updates briefly before retrying: std::bad_cast
Jul 15, 2023 11:17:06.581 [0x7fbce391eb38] Warning — [Req#95d3] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:17:06.581 [0x7fbce391eb38] Warning — [Req#95d3] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Jul 15, 2023 11:17:36.505 [0x7fbce48e2b38] Error — LibraryUpdater: exception updating libraries; pausing updates briefly before retrying: std::bad_cast
Jul 15, 2023 11:17:36.590 [0x7fbce59d3b38] Warning — [Req#995f] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Jul 15, 2023 11:17:36.590 [0x7fbce59d3b38] Warning — [Req#995f] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.

You have DEBUG logging disabled.
As such, we can’t see the real issue.

Is it possible to get a set of DEBUG logs which capture the error happening?

1 Like

Hopefully, this helps:

log.txt (13.3 KB)

Confirming this is still 1.29.2.6364 ?

If so, I recommend upgrading to 1.32.5.7210 or better.

A number of these were fixed since 1.29.2

This is a concern:

Jul 15, 2023 11:43:26.888 [0x7f77e1bf3b38] Debug — CERT: incomplete TLS handshake from [::ffff:192.168.1.1]:61516: stream truncated

You have an IPv4 LAN, you can turn off IPV6 in Settings - Server - Network.

Thank you. I just restored from backup and it’s currently doing database migration. Unfortunately, I have to stay on this version because of problems with PMM and slow initial play that my users have been complaining about has been resolved by downgrading.

I actually used your database tools to try and see if it fixes anything.

I’m not sure if the slowness is directly related to collections and/or to PMM, but this is where I got the idea to downgrade from: Adding metadata via API takes way too long with recent Plex server versions

I’ll change the IPV6 setting, thanks for the tip!

Thank you for detailing.

I now understand why you’re staying at the older version.

The final removal of the plug-ins, which had direct internal access, and switching to using API does slow things down measurably.

Eventually, there will be no choice but by then I also would hope the API is quicker.
(this is new code being honed).

I hope my DB optimize tool is helpful to you. I’ve seen it have profound impact on databases.

1 Like

Yes it has helped me more than once in the past. Thanks!

I am back baby!

So… haha tip for those reading. You can’t just restore the folder in /var/lib/plexmediaserver you also have to restore /usr/lib/plexmediaserver

All is fine now! It’s scanning smoothly!

1 Like

Hey Chuck, can you elaborate on this by any chance? Are there improvements to the API in the works?

I wouldn’t say “Improvements in the API”
as much as I’d say “Natural maturing of the code”.

As time goes on, we always find easier / faster / slicker ways of doing the same thing.

That effort results in better experience for everyone who uses it

The “bad_cast” messages came from the switchover process as the old matching/agent (python) went to the new matching/agent (C++).

They are harmless and, if updated now on current release, you shouldn’t be seeing anymore of them.

If you do, “Refresh All Metadat” will address it.

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