Celedhrim / docker-kodi-server

Runs Kodi in headless mode with docker
MIT License
79 stars 20 forks source link

Trying to clean via api hangs #8

Closed Mycah closed 6 years ago

Mycah commented 7 years ago

When trying to use curl to make the headless kodi container clean the db, curl hangs and the db doesn't get cleaned. It may be trying to prompt something in the UI?

curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1}' -H 'content-type: application/json;' http://kodi:kodi@localhost:8085/jsonrpc

kodi.log output: 18:01:28.467 T:139835964626688 INFO: Platinum [neptune.http]: NPT_CHECK failed, result=-20014 (NPT_ERROR_TIMEOUT) [(result)] 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080]: request received for /jsonrpc 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] HTTP/1.1 POST /jsonrpc 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] Accept: / 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] Authorization: Basic a29kaTprb2Rp 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] Content-Length: 60 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] Host: localhost:8085 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] User-Agent: curl/7.47.0 18:01:29.985 T:139836549469952 DEBUG: CWebServer[8080] [IN] content-type: application/json; 18:01:29.985 T:139836549469952 DEBUG: JSONRPC: Incoming request: { "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1} 18:01:29.992 T:139837173213376 NOTICE: CleanDatabase: Starting videodatabase cleanup .. 18:01:29.992 T:139836560041728 DEBUG: CAnnouncementManager - Announcement: OnCleanStarted from xbmc 18:01:29.992 T:139837173213376 DEBUG: Mysql Start transaction 18:01:48.532 T:139836524291840 DEBUG: Thread AESinkNull 139836524291840 terminating 18:02:18.516 T:139835964626688 INFO: Platinum [neptune.http]: NPT_CHECK failed, result=-20014 (NPT_ERROR_TIMEOUT) [(result)]

I never have an issue doing a db update with curl, so I'm not sure what to try to fix it.

curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": 1}' -H 'content-type: application/json;' http://kodi:kodi@localhost:8085/jsonrpc

Celedhrim commented 7 years ago

I don't use curl for this , y use kodi-send (https://packages.debian.org/fr/sid/kodi-eventclients-kodi-send)

And I have this crontab every night

00 6 * * * /usr/bin/kodi-send -a "CleanLibrary(video)"

It work fine

log :

06:00:21.139 T:140358501431488  NOTICE: CleanDatabase: Cleaning videodatabase done. Operation took 00:19

clean up maybe very long , your log say the clean up start , try to clean a full gui kodi on the same database

Mycah commented 7 years ago

Hmm, that doesn't hang my console but it still doesn't complete the cleanup task.

17:07:38.901 T:139929607284928 NOTICE: CleanDatabase: Starting videodatabase cleanup .. 17:07:38.901 T:139928994113280 DEBUG: CAnnouncementManager - Announcement: OnCleanStarted from xbmc 17:07:38.901 T:139929607284928 DEBUG: Mysql Start transaction 17:07:42.149 T:139928751040256 DEBUG: Thread AESinkNull 139928751040256 terminating 17:08:12.106 T:139928323208960 INFO: Platinum [neptune.http]: NPT_CHECK failed, result=-20014 (NPT_ERROR_TIMEOUT) [(result)] 17:08:39.922 T:139928314816256 NOTICE: ES: Client from ::ffff:172.17.0.1 timed out 17:09:02.151 T:139928323208960 INFO: Platinum [neptune.http]: NPT_CHECK failed, result=-20014 (NPT_ERROR_TIMEOUT) [(result)]

I wrote a script to monitor my cleanup request, and if it hangs it restarts the container and tries again. Usually it'll go through but it might take 3 or 4 restarts.

This is the log on a successful request:

17:20:38.526 T:140172043704064 DEBUG: CWebServer[8080]: request received for /jsonrpc 17:20:38.526 T:140172043704064 DEBUG: CWebServer[8080] [IN] HTTP/1.1 POST /jsonrpc 17:20:38.527 T:140172043704064 DEBUG: CWebServer[8080] [IN] Accept: / 17:20:38.527 T:140172043704064 DEBUG: CWebServer[8080] [IN] Authorization: Basic a29kaTprb2Rp 17:20:38.527 T:140172043704064 DEBUG: CWebServer[8080] [IN] Content-Length: 60 17:20:38.527 T:140172043704064 DEBUG: CWebServer[8080] [IN] Host: localhost:8085 17:20:38.527 T:140172043704064 DEBUG: CWebServer[8080] [IN] User-Agent: curl/7.47.0 17:20:38.527 T:140172043704064 DEBUG: CWebServer[8080] [IN] content-type: application/json; 17:20:38.527 T:140172043704064 DEBUG: JSONRPC: Incoming request: { "jsonrpc": "2.0", "method": "VideoLibrary.Clean", "id": 1} 17:20:38.543 T:140172667447488 NOTICE: CleanDatabase: Starting videodatabase cleanup .. 17:20:38.543 T:140172054275840 DEBUG: CAnnouncementManager - Announcement: OnCleanStarted from xbmc 17:20:38.543 T:140172667447488 DEBUG: Mysql Start transaction 17:20:39.005 T:140172667447488 DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://tank/Workout/Tae Bo Advanced.mkv] 17:20:39.005 T:140172667447488 DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://tank/Workout/Tae Bo Basic.mkv] 17:20:39.006 T:140172667447488 DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://tank/Workout/Tae Bo Live Basic.mkv] 17:20:39.065 T:140172667447488 DEBUG: CleanDatabase: Cleaning paths that don't exist and have content set... 17:20:39.102 T:140172667447488 DEBUG: CleanDatabase: Cleaning tvshow table 17:20:39.102 T:140172667447488 DEBUG: CleanDatabase: Cleaning path table 17:20:39.102 T:140172667447488 DEBUG: Mysql execute: DELETE FROM path WHERE (strContent IS NULL OR strContent = '') AND (strSettings IS NULL OR strSettings = '') AND (strHash IS NULL OR strHash = '') AND (exclude IS NULL OR exclude != 1) AND (idParentPath IS NULL OR NOT EXISTS (SELECT 1 FROM (SELECT idPath FROM path) as parentPath WHERE parentPath.idPath = path.idParentPath)) AND NOT EXISTS (SELECT 1 FROM files WHERE files.idPath = path.idPath) AND NOT EXISTS (SELECT 1 FROM tvshowlinkpath WHERE tvshowlinkpath.idPath = path.idPath) AND NOT EXISTS (SELECT 1 FROM movie WHERE movie.c23 = path.idPath) AND NOT EXISTS (SELECT 1 FROM episode WHERE episode.c19 = path.idPath) AND NOT EXISTS (SELECT 1 FROM musicvideo WHERE musicvideo.c14 = path.idPath) 17:20:39.104 T:140172667447488 DEBUG: CleanDatabase: Cleaning genre table 17:20:39.104 T:140172667447488 DEBUG: Mysql execute: DELETE FROM genre WHERE NOT EXISTS (SELECT 1 FROM genre_link WHERE genre_link.genre_id = genre.genre_id) 17:20:39.104 T:140172667447488 DEBUG: CleanDatabase: Cleaning country table 17:20:39.104 T:140172667447488 DEBUG: Mysql execute: DELETE FROM country WHERE NOT EXISTS (SELECT 1 FROM country_link WHERE country_link.country_id = country.country_id) 17:20:39.105 T:140172667447488 DEBUG: CleanDatabase: Cleaning actor table of actors, directors and writers 17:20:39.105 T:140172667447488 DEBUG: Mysql execute: DELETE FROM actor WHERE NOT EXISTS (SELECT 1 FROM actor_link WHERE actor_link.actor_id = actor.actor_id) AND NOT EXISTS (SELECT 1 FROM director_link WHERE director_link.actor_id = actor.actor_id) AND NOT EXISTS (SELECT 1 FROM writer_link WHERE writer_link.actor_id = actor.actor_id) 17:20:39.151 T:140172667447488 DEBUG: CleanDatabase: Cleaning studio table 17:20:39.151 T:140172667447488 DEBUG: Mysql execute: DELETE FROM studio WHERE NOT EXISTS (SELECT 1 FROM studio_link WHERE studio_link.studio_id = studio.studio_id) 17:20:39.152 T:140172667447488 DEBUG: CleanDatabase: Cleaning set table 17:20:39.152 T:140172667447488 DEBUG: Mysql execute: DELETE FROM sets WHERE NOT EXISTS (SELECT 1 FROM movie WHERE movie.idSet = sets.idSet) 17:20:39.153 T:140172667447488 DEBUG: Mysql commit transaction 17:20:39.154 T:140172667447488 NOTICE: CleanDatabase: Cleaning videodatabase done. Operation took 00:00 17:20:39.154 T:140172054275840 DEBUG: CAnnouncementManager - Announcement: OnCleanFinished from xbmc 17:20:39.154 T:140172043704064 DEBUG: CWebServer[8080] [OUT] Accept-Ranges: none 17:20:39.154 T:140172043704064 DEBUG: CWebServer[8080] [OUT] Cache-Control: private, max-age=0, no-cache 17:20:39.154 T:140172043704064 DEBUG: CWebServer[8080] [OUT] Content-Length: 38 17:20:39.154 T:140172043704064 DEBUG: CWebServer[8080] [OUT] Content-Type: application/json 17:20:39.154 T:140172043704064 DEBUG: CWebServer[8080] [OUT] HTTP/1.1 200 /jsonrpc 17:20:46.801 T:140171316012800 INFO: Platinum [neptune.http]: NPT_CHECK failed, result=-20014 (NPT_ERROR_TIMEOUT) [(result)] 17:21:06.900 T:140171945170688 DEBUG: Thread AESinkNull 140171945170688 terminating 17:21:36.851 T:140171316012800 INFO: Platinum [neptune.http]: NPT_CHECK failed, result=-20014 (NPT_ERROR_TIMEOUT) [(result)]

When it works, it takes less than a second.

Celedhrim commented 7 years ago

And with a full gui version of kodi ? Same ?

I can't figure the relation with docker headless and library cleanup.

peterchs commented 7 years ago

When I've tried clean it does block until the clean completes. If you wait it should return. Dunno if this is a patch or core Kodi issue, but it's not a problem for me, I don't clean that often.