Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plextraktsync hangs while syncing #2107

Open
2 of 3 tasks
U1F984 opened this issue Dec 9, 2024 · 6 comments
Open
2 of 3 tasks

Plextraktsync hangs while syncing #2107

U1F984 opened this issue Dec 9, 2024 · 6 comments

Comments

@U1F984
Copy link

U1F984 commented Dec 9, 2024

Confirmation

  • I have read the README.md on the project homepage
  • I have checked if identical issue already exists
  • I have tried downgrading to find version that can be used as a workaround

The problem

The sync process stops. No more CPU is consumed. This happens randomly (I'd estimate 2/3s of the time, the other 1/3 it runs without issue).

I'm attempting to get a stacktrace of what the process is doing using PYTHONFAULTHANDLER=1 and will report back when I have such a stacktrace.

Steps to reproduce the behavior

  1. Install crontab entry to run docker compose run --rm plextraktsync daily
  2. Wait for 1-2 weeks
  3. Observe stuck processes

Error trace / logs

Here's the relevant containers:

root        1933  0.0  0.3 1237940 8044 ?        Sl   Nov29   6:58 /usr/bin/containerd-shim-runc-v2 -namespace moby -id d9f7c686d9396012dc858bfcffe1abc3f7278d747b94c79e1a539dbd798a36e
1000        1954  0.0 13.1 294344 275500 ?       Ssl  Nov29 160:54  \_ python -m plextraktsync sync
root        2618  0.0  0.3 1238196 8060 ?        Sl   Nov30   6:11 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 4c183f15c85e30b82f6ad1340414e8c98c92642157a9468ea5c89b4a3c4afca
1000        2640  0.0  2.7  73332 56824 ?        Ssl  Nov30 117:23  \_ python -m plextraktsync sync
root        7299  0.0  0.3 1238196 8284 ?        Sl   Dec07   1:17 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 018d97d2c456cc9f1cde7bacbe1dc679704b3d8b49b53dfe2be134a2155f23a
1000        7319  0.0 21.8 478428 458764 ?       Ssl  Dec07  70:38  \_ python -m plextraktsync sync
root        7950  0.0  0.4 1238196 10100 ?       Sl   Dec08   0:44 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 322f664b7cba8bee7ad92b5718571351a4e4636eaa24233970dc4534f71aa34
1000        7971  0.0 10.9 242876 230112 ?       Ssl  Dec08  24:40  \_ python -m plextraktsync sync

Sample log ending (different containers have different endings):

[...]
INFO     Preloaded shows data (12067 shows)                                     
INFO     Preload shows matches                                                  
WARNING  9/11 - Animal Squad | Pen & Paper (2017): Skipping                     
         <PlexGuid:tvdb://326417> not found on Trakt

Expected behavior

Sync takes some time and then finishes.

Inspect of problematic items

No response

Workarounds

I'm also now executing it with timeout 22h docker compose run ... so that the containers will stop accumulating.

Config file contents

cache:
  path: /app/config/trakt_cache
excluded-libraries:
- Private
- Family Holidays
config:
  dotenv_override: true
plex:
  timeout: 30
logging:
  append: true
  console_time: false
  debug: false
  filename: plextraktsync.log
  filter_loggers: null
  filter: null
sync:
  rating_priority: plex
  plex_to_trakt:
    collection: true
    clear_collected: false
    ratings: true
    watched_status: true
    watchlist: true
  trakt_to_plex:
    liked_lists: true
    ratings: true
    watched_status: true
    watchlist: true
    watchlist_as_playlist: false
    playback_status: false
liked_lists:
  keep_watched: true
watch:
  add_collection: false
  remove_collection: false
  scrobble_threshold: 80
  username_filter: true
  media_progressbar: true
  ignore_clients: null
xbmc-providers:
  movies: imdb
  shows: tvdb

Install method

docker-compose

Version

0.32.2

Python Version

3.13.0

Plex Server Version

1.41.2.9200

Operating System and Version

Linux-6.8.8-3-pve-x86_64-with

@U1F984
Copy link
Author

U1F984 commented Dec 10, 2024

Here's the thread dump:

Fatal Python error: Aborted

Thread 0x0000767d529ffb38 (most recent call first):
  File "/app/plextraktsync/queue/BackgroundTask.py", line 64 in __call__
  File "/usr/local/lib/python3.13/threading.py", line 992 in run
  File "/usr/local/lib/python3.13/threading.py", line 1041 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1012 in _bootstrap

Thread 0x0000767d59665b38 (most recent call first):
  File "/usr/local/lib/python3.13/threading.py", line 363 in wait
  File "/usr/local/lib/python3.13/threading.py", line 659 in wait
  File "/usr/local/lib/python3.13/site-packages/rich/live.py", line 29 in run
  File "/usr/local/lib/python3.13/threading.py", line 1041 in _bootstrap_inner
  File "/usr/local/lib/python3.13/threading.py", line 1012 in _bootstrap

Current thread 0x0000767d682f2b08 (most recent call first):
  File "/usr/local/lib/python3.13/ssl.py", line 1138 in read
  File "/usr/local/lib/python3.13/ssl.py", line 1304 in recv_into
  File "/usr/local/lib/python3.13/socket.py", line 719 in readinto
  File "/usr/local/lib/python3.13/http/client.py", line 292 in _read_status
  File "/usr/local/lib/python3.13/http/client.py", line 331 in begin
  File "/usr/local/lib/python3.13/http/client.py", line 1428 in getresponse
  File "/usr/local/lib/python3.13/site-packages/urllib3/connection.py", line 507 in getresponse
  File "/usr/local/lib/python3.13/site-packages/urllib3/connectionpool.py", line 536 in _make_request
  File "/usr/local/lib/python3.13/site-packages/urllib3/connectionpool.py", line 789 in urlopen
  File "/usr/local/lib/python3.13/site-packages/requests/adapters.py", line 667 in send
  File "/usr/local/lib/python3.13/site-packages/requests/sessions.py", line 703 in send
  File "/usr/local/lib/python3.13/site-packages/requests_cache/session.py", line 254 in _send_and_cache
  File "/usr/local/lib/python3.13/site-packages/requests_cache/session.py", line 230 in send
  File "/usr/local/lib/python3.13/site-packages/requests/sessions.py", line 589 in request
  File "/usr/local/lib/python3.13/site-packages/requests_cache/session.py", line 183 in request
  File "/usr/local/lib/python3.13/site-packages/trakt/core.py", line 544 in _handle_request
  File "/usr/local/lib/python3.13/site-packages/trakt/core.py", line 579 in inner
  File "/app/plextraktsync/trakt/TraktApi.py", line 306 in search_by_id
  File "/app/plextraktsync/decorators/retry.py", line 26 in retry
  File "/usr/local/lib/python3.13/site-packages/decorator.py", line 232 in fun
  File "/app/plextraktsync/decorators/rate_limit.py", line 20 in rate_limit
  File "/usr/local/lib/python3.13/site-packages/decorator.py", line 232 in fun
  File "/app/plextraktsync/trakt/TraktApi.py", line 259 in find_by_guid
  File "/app/plextraktsync/trakt/TraktApi.py", line 344 in find_episode_guid
  File "/app/plextraktsync/media/MediaFactory.py", line 66 in resolve_guid
  File "/app/plextraktsync/media/MediaFactory.py", line 39 in resolve_any
  File "/app/plextraktsync/plan/Walker.py", line 138 in find_episodes
  File "/app/plextraktsync/sync/Sync.py", line 52 in sync
  File "/app/plextraktsync/commands/sync.py", line 13 in run_async
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89 in _run
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 2027 in _run_once
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 679 in run_forever
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 708 in run_until_complete
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 118 in run
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 194 in run
  File "/app/plextraktsync/decorators/coro.py", line 15 in coro
  File "/usr/local/lib/python3.13/site-packages/decorator.py", line 232 in fun
  File "/app/plextraktsync/commands/sync.py", line 74 in sync
  File "/app/plextraktsync/cli.py", line 28 in wrap
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 783 in invoke
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1434 in invoke
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1688 in invoke
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1078 in main
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1157 in __call__
  File "/app/plextraktsync/__main__.py", line 20 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_mai

@U1F984
Copy link
Author

U1F984 commented Dec 10, 2024

I have copied out the /usr/local/lib/python3.13/site-packages/trakt/core.py and patched it with timeout=30 at all locations as a possible workaround.

@glensc
Copy link
Collaborator

glensc commented Dec 11, 2024

you can submit fixes to trakt module here:

@glensc

This comment was marked as off-topic.

@glensc

This comment was marked as off-topic.

@glensc glensc closed this as completed Dec 12, 2024
@glensc glensc reopened this Dec 12, 2024
@glensc
Copy link
Collaborator

glensc commented Dec 12, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants