Strange Optimizer bug?

Server Version#: 1.19.5.3112
Player Version#: NA

I have been optimizing versions of TV shows I have recorded for some time now, and suddenly yesterday, I recorded a new show and It refuses to optimize. error is “Converted files cannot be written to the server’s disk”. Some points to note:

  • Plex server runs on Windows
  • The disk is local, and it is the same disk that records the show
  • Lots of other shows recode to the exact same location, and they all work fine
  • The disk has plenty of space (around 3 TB, it is at 50%)

There are some strange anomalies. In order to test the disk write itself, I copied the original “.ts” file over to the “Plex Versions” directory where it would be placed after recode, it worked perfectly fine, the file can be written there without any issue. Then I noticed that another show which is also being optimized started an optimization for no reason. When I looked, the file I just copied in to the “Plex Versions” location was now being used as a source for an optimization for a completely different show. Something is drastically wrong here, can someone help me debug. So to explain exactly what I saw:

  1. I am recording “The Chase” in to J:\Recode\The Chase. The folder is being monitored, and when a new episode appears it will be optimized in to J:\Recode\Plex Versions. It has worked for a while, and had no issues yesterday.

  2. I am recording “The Yorkshire Vet” in to J:\Recode\The Yorkshire Vet. I have set up for this folder for optimization also, and it should optimize in to J:\Recode\Plex Versions, but this optimization always fails with the above error

  3. When I manually copy the .ts “The Yourshire Vet” recording from “J:\Recode\The Yorkshire Vet\The Yorkshire Vet_2020-08-24.ts” to “J:\Recode\Plex Versions\Original Quality\The YorkshireVet\The Yorkshire Vet_2020-08-24.ts” suddenly, for no apparent reason, the auto-optimization for “The Chase” kicks in and creates an optimized version of the file in the “The Yorkshire Vet” direcory in to an optimized version, placing it in “The Chase” optimized location.

So, what’s going on here? It seems like a weird naming bug in Plex. Note that both shows start with "The ".

Any way to debug what is happening?

Thanks

I found this in the error log:

Aug 24, 2020 12:38:59.306 [0944] WARN - IsDirWritable: directory ‘"J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet "’ is not writable^M
Aug 24, 2020 12:38:59.306 [0944] ERROR - TranscodeJobManager: [Running] directory is not writable: "J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet "^M
Aug 24, 2020 12:38:59.307 [0944] DEBUG - BPQ: setOverrideState for generator 7291: failed/diskUnwritable^M
Aug 24, 2020 12:38:59.307 [0944] DEBUG - BPQ: generator 7291 changed state: pending -> failed^M
Aug 24, 2020 12:38:59.307 [0944] DEBUG - BPQ: reprocessing requested while processing item^M
Aug 24, 2020 12:38:59.307 [0944] DEBUG - BPQ: onConsiderProcessing: Processing (true)^M
Aug 24, 2020 12:38:59.307 [0944] DEBUG - Versions: updating status for generator 7291^M

It makes no sense, the location has always been writable and works for other optimizations

I found a glitch, not sure if it is relevant:

Aug 24, 2020 12:38:59.306 [11216] INFO - Library section 13 (Recode) will be updated because of a change in ‘“J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet”/’^M
Aug 24, 2020 12:38:59.306 [0944] ERROR - IsFileWritable: failed to create file ‘“J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet \85c03a0c-0e26-4b5a-9d40-ef4ee5c6cf47”’^M
Aug 24, 2020 12:38:59.306 [0944] WARN - IsDirWritable: directory ‘"J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet "’ is not writable^M

Look very carefully at the first message above, note that the directory name has no trailing space, it is exactly

'“J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet”.

Yet, when it tries to recode and has an error creating a file, it states:

failed to create file '“J:\Recode\Plex Versions\Original Quality\The Yorkshire Vet \85c03a0c-0e26-4b5a-9d40-ef4ee5c6cf47”

Note that there is a space at the end of the directory name. Of course this fails, that directory does not exist. Is this some kind of bug in the code?

Crazy!!.

So, I had to use my Linux machine to do this (I have a SAMBA mount to the Windows Plex server), and it is not really a good solution, but this is how I fixed it

  1. Went directly to the Optimized Versions directory from my Linux box
  2. Use the Linux command line to create a directory that has a space at the end of the name (very subtle, but it is using the escape to create a dir with a space at the end of the name)

mkdir The\ Yorkshire\ Vet\ /

  1. Go back to Plex in the browser, find the failed recode Settings->Manage->Optimized Versions, and hit the “Redo” button to ask it to try again.

  2. Voila, the optimization works perfectly, and places the optimized versions in the directory with a space at the end of the name.

I’m prety sure this is a Plex bug.

BTW: I just checked from Linux. Before you ask…there is no space at the end of the original directory name where the .ts file is recorded…Plex is just randomly adding a space to the target location when it tries to optimize.

Please provide full logs zip and not snippets of log lines so that this can be progressed

Also would help to include actual screenshots of list directory

Plex Media Server.2.log (10.1 MB)

Filers attached. As you can see I now have 2 “The Yorkshire Vet” dirs in my recode output location. The one with the trailing space contains the files that Plex optimized. Also in the other terminal window, you see that the original directory the .ts file came from does not have a trailing space. The log for the failed optimization is attached.

At this point, I’m using my work-around and it seems to be fine, so no urgency.

BTW: Obvously I used my Linux box to show the files through a SAMBA mount because that way you can see the trailing space in the directories, but the disk and the Plex server are both on a Windows machine, this is just a mount-point.

This problem happened again with a completely diferent folder name last night. I started recording a new show in exactly the same place, optimizing to the same place, and optimize failed with the identical error. As soon as I created the directory with the space at the end of the name, it worked fine, and optimized in to the dir with the space.

Note that since last time. I have also recorded another new show and optimized it without seeing this issue. The problem is intermittent…good luck finding this bug guys, somehow I think it will be a challenge. If you need any logs or you want me to run a diag version just DM me. SInce I have a reliable work-around I’m fine.

BTW: I also upgraded to 1.20.1.3252.

Thank you for the log and directory details.

There would be two potential fixes for this - truncating trailing space in title when optimizing or making sure no trailing space is saved in the title

As you can see there is a space at the end of the title - between “Vet” and the “)” character

Aug 24, 2020 12:33:09.608 [12312] DEBUG - Item 147602 (The Yorkshire Vet ) Scanning metadata graphic elements in XML file ""/Info.xml

So what i need to do first is establish how that trailing space got added to the recording path and if it was Plex Media Server doing it at the end of the recording

Can you get me logs covering the time of recording a show that ends up with this issue
and media info xml for the episode - see https://support.plex.tv/articles/201998867-investigate-media-information-and-formats/

It’s not actually Plex doing the recording, so in fact there is no XML file in the folder in this case. Here’s how the setup works:

  1. On a machine running Debian Linux, NextPVR records a TV show, and writes it to a disk on the Windows Plex server (mounted via a SAMBA mount). I have switched off XML generation for NextPVR since this XML format is useless to Plex, and I never watch anything from NextPVR directly anyway. No XML file is generated.

  2. The directory being written to by NextPVR is being constantly monitored by the Plex server, and I have an Optimizer job set up for this directory, so when a new file appears here (from the NextPVR recording), the Plex server adds it to the library, and then automatically optimizes it. The optimization is set to place the optimized version in a separate “Plex Versions” location, not “In folders with Original Items”.

  3. As you see from the screenshot, the original directory written to (and created) by NextPVR does not contain any trailing space in the directory name, and Plex seems to add it to the library and correctly find the show name from TheTVDB.

  4. However, when trying to optimize the new episode, Plex creates a new directory under “Plex Versions” with the same name as the original directory, and then, when optimizing the .ts file to a .mp4, it tries to write the output to a directory which does contain a space in the name; this directory does not exist and it causes the error.

I don’t know if the NextPVR logs are of any use to you since this part of the equation seems to be fine, and Plex is not involved anyway. Once Plex starts processing the file for optimization, it seems to go awry.

Given this explanation, let me know if there are any logs which are useful to you.

So the file that is generated here does not have a trailing space.

Could you check the file produced to see if there are any metadata tags and if there is a title tag with a space at the end

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

This has now been fixed

Fix released in Plex Media Server beta 1.25.2.5319-c43dc0277

  • (Optimized Versions) Conversions would fail on Windows if the item title contained trailing spaces (#13128)
1 Like