i had a issue that presented itself the same way as OP it went away after i changed the owner of the plexdata folder and the relevant subdirectories in /var/db to be plex and not root after i changed that i could optimize the databate without crashes.
So:
chown -Rf plex:wheel /var/db/plexdata
and then optimize and my issues where gone