`Plex SQLite` utility on FreeBSD fails

Server Version#: 1.23.2.4656-85f0adf5b

The new Plex SQLite utility fails on a TrueNAS-12.0-U4 system, in a 12.2, 11.4, or 11.2 jail.

root@plex:/usr/local/share/plexmediaserver # ./Plex\ SQLite /path/to/com.plexapp.plugins.library.db
Initial sysctl failed: 22
 18232 Plex SQLite CALL  __sysctl(0x1021afc,0x3,0x7fffffffe9d0,0x7fffffffe9a8,0,0)              
 18232 Plex SQLite SCTL  "kern.proc.pathname"
 18232 Plex SQLite RET   __sysctl -1 errno 22 Invalid argument

I wondered if something depended on procfs, but mounting /proc doesn’t change anything.

You might need to export LD_LIBRARY_PATH, but unsure if it’s enough, it. might not be properly built for FreeBSD too.

Usually I just install sqlite locally if I need it

1 Like

Thanks! LD_LIBRARY_PATH doesn’t change anything.

I should have mentioned that ./Plex\ Media\ Server --sqlite works. I’m not having an actual problem.

I saw Plex SQLite mentioned in another thread, and was nosing around. It looks like a wrapper utility anyway? I figure the “How to Repair a Corrupt Database” documentation will get updated soon.

Feel free to ignore me. :slight_smile:

I just noticed that the Repair a Corrupted Database documentation has been updated. (Yay!)

For anybody searching - as of 1.23.3, the issue with Plex\ SQLite still exists on FreeBSD (or TrueNAS).

./Plex\ Media\ Server --sqlite works fine as an alternative.

Thanks much for the report, and the detailed trace! Could you try out this build? I believe it should fix the issue for you.

It changes the error, does that count? :slight_smile:

root@plex:/usr/local/src/PlexMediaServer-1.23.5.4701-aca01509d # ktrace ./Plex\ SQLite
Final sysctl failed: 12
root@plex:/usr/local/src/PlexMediaServer-1.23.5.4701-aca01509d # kdump | tail -n 15
 34310 Plex SQLite RET   mmap 34389278720/0x801c2c000
 34310 Plex SQLite CALL  mprotect(0x1024000,0x1000,0x1<PROT_READ>)
 34310 Plex SQLite RET   mprotect 0
 34310 Plex SQLite CALL  __sysctl(0x1021b00,0x4,0x7fffffffea20,0x7fffffffe9f8,0,0)
 34310 Plex SQLite SCTL  "kern.proc.pathname.-1"
 34310 Plex SQLite RET   __sysctl -1 errno 12 Cannot allocate memory
 34310 Plex SQLite CALL  __sysctl(0x1021b00,0x4,0x7fffffffea20,0x7fffffffe9f8,0,0)
 34310 Plex SQLite SCTL  "kern.proc.pathname.-1"
 34310 Plex SQLite RET   __sysctl -1 errno 12 Cannot allocate memory
 34310 Plex SQLite CALL  write(0x2,0x7fffffffe2f0,0x18)
 34310 Plex SQLite GIO   fd 2 wrote 24 bytes
       "Final sysctl failed: 12
       "
 34310 Plex SQLite RET   write 24/0x18
 34310 Plex SQLite CALL  exit(0x2)

Yes! That’s progress! Try this one.

1 Like
root@plex:/usr/local/src/PlexMediaServer-1.23.5.4702-efe9a58fb # ./Plex\ SQLite
SQLite version 3.35.5 2021-04-19 18:32:05
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open /tmp/com.plexapp.plugins.library.db
sqlite> PRAGMA integrity_check;
ok

Woohoo!

Nice, and thanks much for the assistance with this! We’ll get this fix pushed out in an upcoming PMS release.

Some random extra facts: Plex SQLite is really just a helper stub that re-execs Plex Media Server with the same argv it was passed. The PMS code that checks for the --sqlite argument in argv[1] also checks for Plex SQLite in argv[0]; it’s very busybox-style. So a symlink would’ve worked just as well, but getting all of our installers across all platforms to play nice with symlinks would’ve been way more complex than just writing a tiny stub executable.

Bonus: we can also just make additional unmodified copies of this executable to reuse for any other additional CLI functions we build into PMS! Look out for those in the future :stuck_out_tongue:

1 Like

That’s clever, and thanks for sharing the details!

Resolved in 1.23.4.4712.

Plex Media Server - #441 by janoskk

Thanks!

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