Maintainerr icon indicating copy to clipboard operation
Maintainerr copied to clipboard

Items get repeatedly removed and added back to collections

Open Zipties opened this issue 1 year ago • 100 comments

I am having an issue where all items in the collection are being removed each night, and then being added again shortly after

image

All my rules are exhibiting this behavior and I am pretty stumped over it. Here is one of them

rules:
 - "0":
     - firstValue: Plex.seenBy
       action: CONTAINS
       lastValue: Overseerr.addUser
     - operator: AND
       firstValue: Overseerr.isRequested
       action: EQUALS
       customValue:
         type: boolean
         value: "true"
     - operator: AND
       firstValue: Overseerr.mediaAddedAt
       action: BEFORE
       customValue:
         type: custom_days
         value: "90"
     - operator: AND
       firstValue: Radarr.tags
       action: NOT_CONTAINS_PARTIAL
       customValue:
         type: text
         value: dnd
 - "1":
     - operator: OR
       firstValue: Overseerr.mediaAddedAt
       action: BEFORE
       customValue:
         type: custom_days
         value: "60"
     - operator: AND
       firstValue: Overseerr.isRequested
       action: EQUALS
       customValue:
         type: boolean
         value: "true"
     - operator: AND
       firstValue: Radarr.tags
       action: NOT_CONTAINS_PARTIAL
       customValue:
         type: text
         value: dnd
 - "2":
     - operator: OR
       firstValue: Plex.lastViewedAt
       action: BEFORE
       customValue:
         type: custom_days
         value: "365"
     - operator: AND
       firstValue: Radarr.tags
       action: NOT_CONTAINS_PARTIAL
       customValue:
         type: text
         value: dnd
 - "3":
     - operator: OR
       firstValue: Plex.viewCount
       action: EQUALS
       customValue:
         type: number
         value: 0
     - operator: AND
       firstValue: Plex.addDate
       action: BEFORE
       customValue:
         type: custom_days
         value: "730"
     - operator: AND
       firstValue: Radarr.tags
       action: NOT_CONTAINS_PARTIAL
       customValue:
         type: text
         value: dnd

Zipties avatar Dec 19 '24 19:12 Zipties

Could you enable debug logging: https://docs.maintainerr.info/Installation.html#enabling-debug-logging

Wait for this to happen a few more times and then attach the logs here.

I'd also suggest using Test Media on one of those seasons a few times per day, save the results and then compare and/or attach here.

benscobie avatar Dec 19 '24 23:12 benscobie

Been busy with holiday plans but didn't want to leave this stale. I grabbed the debug logs but haven't looked at them yet, it is still happening though. maintainerr-2024-12-23.log

Zipties avatar Dec 24 '24 02:12 Zipties

Been busy with holiday plans but didn't want to leave this stale. I grabbed the debug logs but haven't looked at them yet, it is still happening though. maintainerr-2024-12-23.log

It looks like you may have a mixture of things happening. I could be wrong. You are having A LOT of TMDB/TVDB id errors. Maintainerr uses these IDs to talk with *arr services to make sure we are talking about the exact same movie. These IDs come from your Plex metadata.

When Maintainerr tries to remove the items, it can't tell the other services to do something with them, because those services are saying "that item doesn't exist". It technically does but not with the information that Maintainerr is sending it, that it got from Plex. see #1469 for another discussion on the topic.

The other thing I wanted to ask about is if you are using Smart Collections, with Custom Collections in Maintainerr? I see this in your logs:

[maintainerr]  |  23/12/2024 08:10:47  [WARN] [PlexApiService] Couldn't find collection with id 385545
[maintainerr]  |  23/12/2024 08:10:47  [DEBUG] [PlexApiService] Plex Server didnt respond with a valid 2xx status code, response code: 404
[maintainerr]  |  23/12/2024 08:10:47  [WARN] [CollectionsService] An error occurred while searching for a specific Plex collection.
[maintainerr]  |  23/12/2024 08:10:47  [DEBUG] [CollectionsService] Cannot read properties of undefined (reading 'smart')

I believe that cleaning up your metadata, in Plex, is going to solve a lot of your problems, and at the very least it is going to clean up your Maintainerr logs.

https://support.plex.tv/articles/201018497-fix-match-match/

ydkmlt84 avatar Dec 29 '24 21:12 ydkmlt84

I am starting to feel this is probably some kind of conflict with kometa. Does it seem plausible it could be doing something to cause the tvdb and metadata errors? I do database and metadata cleanups weekly in a scheduled job

it makes a lot of sense though, because I noticed files are downloading again when maintainarr does manage to remove them, because it isn't unmonitoring them as configured.

The other thing I wanted to ask about is if you are using Smart Collections, with Custom Collections in Maintainerr? I see this in your logs:

I jsut have maintainarr set to create its own collections, I am not trying to do anything fancy. Kometa makes numerous collections smart and otherwise though. I made sure kometa is set not to delete unknown collections and confirmed it wasn't deleting maintainarrs.

Zipties avatar Dec 31 '24 16:12 Zipties

I use Kometa but almost exclusively for overlays and a few collections. Maybe try to make a rule that would match a small section of your library, and see if ensuring the metadata for those specific items, makes any kind of difference.

ydkmlt84 avatar Dec 31 '24 18:12 ydkmlt84

I disabled Kometa, and did a fresh metadata cleanup and still see the flood of API errors in the logs you pointed out.

[maintainerr]  |  01/01/2025 16:00:07  [WARN] [RadarrApi] Could not find Movie with TMDb id 280 in Radarr
[maintainerr]  |  01/01/2025 16:00:07  [DEBUG] [RadarrGetterService] Couldn't fetch Radarr metadate for media 'Terminator 2: Judgment Day' with id '235900'. As a result, no Radarr query could be made.

These seem to be because I have another radarr instance for 4k movies. I added the 4k server, but im not sure how I'd include both servers in the rule.

I think that may be a redherring though, as I don't see sonarr errors in the logs, and TV shows have the same issue. I only have a single sonarr instance. I spot checked a handful like the below which do exist in sonarr, and do not have errors in the logs

CleanShot 2025-01-01 at 21 41 00 I don't see anything in the logs referencing the show, so I assume it's under an id.

 plexId: 237511
  result: true
  sectionResults:
    - id: 0
      result: true
      ruleResults:
        - operator: OR
          action: contains_partial
          firstValueName: Sonarr - [list] Tags (show)
          firstValue:
            - latesttvshows
            - lists
          secondValueName: text
          secondValue: lists
          result: true
        - operator: AND
          action: equals
          firstValueName: Plex - Total views
          firstValue: 0
          secondValueName: number
          secondValue: 0
          result: true
        - operator: AND
          action: before
          firstValueName: Sonarr - Date added
          firstValue: 2024-11-05T03:57:06.000Z
          secondValueName: custom_days
          secondValue: 2024-12-19T03:43:18.215Z
          result: true

Zipties avatar Jan 02 '25 03:01 Zipties

I experience this exact issue as well, and have for some time. I also use Kometa regularly, make use of collections heavily, and have a decent sized Movie library (~1200+ movies). TV Shows do not experience this problem for me.

I also use the Plex Meta Cleanup (now called ImageMaid) on a weekly basis to keep my database clean as I’ve had issues in the past, but this routine seems to keep my database clean as I haven’t had any plex issues in over a year.

I do not have a separate Radarr instance for 4k, just single.

Happy to also test or provide logs. I’d love to get this solved.

mlamoure avatar Jan 04 '25 03:01 mlamoure

I have the same and had it for quite some time now, before I had Kometa and ImageMaid and after.

I also have brought up the issue before in issue #1140.

My comment on the issue

You get a lot of log messages in Maintainerr like these:

removed *movie/show* and added *movie/show

But what you don't see are the usual successfully handled *movie/show*

If you look at the logs of Sonarr and Radarr at the times of those 'removed' messages from Maintainerr, there are no api calls to remove/delete/unmonitor the particular media.

appiekap653 avatar Jan 15 '25 10:01 appiekap653

The adding & removing loop is typically because the Plex metadata has differing TVDB IDs to Sonarr/Radarr. In the Docker logs you'll see something like [maintainerr] | 01/10/2024 14:20:52 [WARN] [SonarrGetterService] [TVDB] Failed to fetch tvdb id for 'Some TV Show'. That can sometimes be resolved by fixing the match in Plex: https://docs.maintainerr.info/Common/#tvdbid-or-tmdbid-errors

Could you check your Docker logs to see if this is the case for you? Enable debug logging too if you haven't already as that can provide more info for us: https://docs.maintainerr.info/Installation/#enabling-debug-logging_1

I want to make a change where the item is not removed from the collection unless it was successfully handled. That does mean it'll get stuck in the collection and go into negative days to remove, but at least it's more obvious. Long term I think we should surface that particular problem somewhere in the UI so you don't have to go digging around in logs. Then perhaps we provide some way to override the IDs from Plex so these items can get handled correctly.

benscobie avatar Jan 15 '25 10:01 benscobie

This issue has been marked stale because it has been 30 days with no activity.

github-actions[bot] avatar Feb 15 '25 04:02 github-actions[bot]

Just checking back in on this to see if anyone has any ideas. All my TV shows have the below behavior. I don't see any IMDB errors being reported, and my media is tagged with the correct IDs. Movies has the same rules but doesn't appear to have the issue although it's a much smaller dataset

Version 2.10.0

- plexId: 237638
  result: true
  sectionResults:
    - id: 0
      result: false
      ruleResults:
        - operator: OR
          action: contains_partial
          firstValueName: Sonarr - [list] Tags (show)
          firstValue:
            - appletv
            - lists
          secondValueName: text
          secondValue: lists
          result: true
        - operator: AND
          action: not_contains_partial
          firstValueName: Sonarr - [list] Tags (show)
          firstValue:
            - appletv
            - lists
          secondValueName: text
          secondValue: dnd
          result: true
        - operator: AND
          action: before
          firstValueName: Plex - Last view date
          firstValue: null
          secondValueName: custom_days
          secondValue: 7776000
          result: false
    - id: 1
      result: true
      operator: OR
      ruleResults:
        - operator: OR
          action: equals
          firstValueName: Plex - Total views
          firstValue: 0
          secondValueName: number
          secondValue: 0
          result: true
        - operator: AND
          action: contains
          firstValueName: Sonarr - [list] Tags (show)
          firstValue:
            - appletv
            - lists
          secondValueName: text
          secondValue: lists
          result: true
        - operator: AND
          action: not_contains_partial
          firstValueName: Sonarr - [list] Tags (show)
          firstValue:
            - appletv
            - lists
          secondValueName: text
          secondValue: dnd
          result: true

Image

Image

Image

Zipties avatar Feb 27 '25 19:02 Zipties

It's interesting that you experience it on TV shows. I experience the problem of coming on and off the Maintainerr lists on Movies only. I have Kometa applied to both.

mlamoure avatar Feb 27 '25 23:02 mlamoure

@mlamoure @Zipties Could you enable debug logging, wait for an add & remove cycle and then share your logs please.

benscobie avatar Feb 28 '25 16:02 benscobie

@mlamoure @Zipties Could you enable debug logging, wait for an add & remove cycle and then share your logs please.

maintainerr-2025-02-28.log

Sorry, I had them enabled but forgot to upload. I see a lot of plex API communication errors, but I see other API apps cause that from plex throttling the calls, so figured that may be normal

Zipties avatar Feb 28 '25 17:02 Zipties

Here is the 25th which shows adds

maintainerr-2025-02-25.log

here is yesterday's which shows removals

maintainerr-2025-02-27.log

Zipties avatar Feb 28 '25 17:02 Zipties

I think what we'll need to do is include the rule results with the added & removed logs. Then we should be able to identify which rule(s) are being problematic and go from there.

You have a ton of seasons is not iterable errors though, but they're in both logs so likely unrelated.

benscobie avatar Mar 03 '25 10:03 benscobie

I think what we'll need to do is include the rule results with the added & removed logs. Then we should be able to identify which rule(s) are being problematic and go from there.

Is there a way to do this programmatically? I keep trying to catch a rule flipping before a run and have never witnessed it.

You have a ton of seasons is not iterable errors though, but they're in both logs so likely unrelated.

yeah, I'm starting to look at that and see if there's anything there. It gives the same error for movies which is odd. I thought maybe it was a case of a movie being in the tv series folder, but thats not the case.

10:08:17 AMWARNPlex-Getter - Action failed for 'Fractured' with id '241926': seasons is not iterable

Image

Zipties avatar Mar 17 '25 15:03 Zipties

@Zipties and any others that are having this issue, I have created a test build that will save rule results (the output you see in Test Media) whenever an add or delete takes place.

If you could update your Docker image to the below (note that it is currently based off of the latest stable release v2.14.0): jorenn92/maintainerr:pr-1705

When you spot the issue in your logs again, click the new (meta) link next to the event message (pictured below). This will open the rule results for that action. If you could share each add & remove that would be great! Image

I am hoping that we'll see one or more rules switching between true and false so we can dig further into those.

benscobie avatar Apr 14 '25 20:04 benscobie

@benscobie running it now, so far the manual rule runs haven't reproduced the issue so I'll give it a day or two.

PS, nice work on the new progress bar

Zipties avatar Apr 16 '25 18:04 Zipties

@benscobie running it now, so far the manual rule runs haven't reproduced the issue so I'll give it a day or two.

PS, nice work on the new progress bar

I forgot to mention, that build also includes a potential fix for this occurring. When we failed to get data for a rule (i.e. network issue, API server timeout etc.) then that rule would be completely ignored, essentially result: true. That could temporarily flip the rule logic meaning the item gets incorrectly added or removed. The next time around the data fetch could succeed which reverses the action. Instead we now mark that media item as failed, so it'll always return result: false. There's still a chance that an item in a collection may get removed due to a data fetch failure, and then added back again the next time. I want to implement a different solution for that where we'll retry a few more times before removing the item from the collection.

I'm glad you like the progress bar!

benscobie avatar Apr 17 '25 10:04 benscobie