Watched count of episodes is not getting updated on seasons-list and titles-list
#1
I have Krypton 17.1 and MySQL 5.7.18 holding the data for my libraries.

I go into the TV Shows and am shown the list of my shows. Selecting a show, I am presented with the seasons in that show (seasons list). I select a season and i am shown all the episodes. i watch one of them. My skin, "Aeon Nox 5: Redux", which shows the number of unwatched episodes, does not show an updated unwatched count when i go "back" to the "season list". Thinking this might be a skin issue, i switched to Confluence and the problem persists.

I checked "tvshow_view" on MySQL and the "watchedcount" value was correctly incremented. I also noticed, from the log snippet below, that no query was run to fetch the season list.

Code:
<!-- Marked as WATCHED -->
17:35:32.594 T:5348   DEBUG: CInputManager::OnKey: w (0xf057) pressed, action is ToggleWatched
17:35:32.650 T:14984   DEBUG: Mysql Start transaction
17:35:32.657 T:14984   DEBUG: Mysql execute: delete from bookmark where idFile=9935 and type=1
17:35:32.663 T:14984   DEBUG: Mysql execute: update files set playCount=1,lastPlayed='2017-05-01 17:35:32' where idFile=9935
17:35:32.667 T:12980   DEBUG: CAnnouncementManager - Announcement: OnUpdate from xbmc
17:35:32.667 T:12980   DEBUG: GOT ANNOUNCEMENT, type: 16, from xbmc, message OnUpdate
17:35:32.676 T:5348   DEBUG: Keyboard: scancode: 0x11, sym: 0x0077, unicode: 0x0000, modifier: 0x0
17:35:32.754 T:14984   DEBUG: Mysql commit transaction
17:35:32.802 T:5348   DEBUG: Clearing cached fileitems [videodb://tvshows/titles/104/1/?tvshowid=104]
17:35:32.804 T:5348   DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/104/1/?tvshowid=104)
17:35:32.804 T:5348   DEBUG:   ParentPath = [videodb://tvshows/titles/104/1/?tvshowid=104]
17:35:33.306 T:5348   DEBUG: ------ Window Init (DialogBusy.xml) ------
17:35:34.993 T:14984   DEBUG: CVideoDatabase::RunQuery took 2141 ms for 24 items query: select * from episode_view  WHERE (episode_view.idShow = 104) AND ((episode_view.c12 = 1 or (episode_view.c12 = 0 and (episode_view.c15 = 0 or episode_view.c15 = 1))))
17:35:35.001 T:5348   DEBUG: Saving fileitems [videodb://tvshows/titles/104/1/?tvshowid=104]
17:35:35.003 T:5348   DEBUG:   -- items: 24, sort method: 0, ascending: true
17:35:35.063 T:5348   DEBUG: WindowVideoNav::GetDirectory
17:35:35.580 T:5348   DEBUG: ------ Window Deinit (DialogBusy.xml) ------
<!-- Going BACK to season list -->
17:35:38.169 T:5348   DEBUG: Keyboard: scancode: 0x0e, sym: 0x0008, unicode: 0x0008, modifier: 0x0
17:35:38.291 T:5348   DEBUG: CInputManager::OnKey: backspace (0xf008) pressed, action is Back
17:35:38.292 T:5348   DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/104/)
17:35:38.292 T:5348   DEBUG:   ParentPath = [videodb://tvshows/titles/]
<!-- CFileItemList::Load from cache here -->
17:35:38.294 T:5348   DEBUG: Loading items: 6, directory: videodb://tvshows/titles/104/ sort method: 0, ascending: true
17:35:38.312 T:5348   DEBUG: WindowVideoNav::GetDirectory


I switched to the built-in database engine and following the steps from before, the unwatched number updates properly on the season list.
Code:
<!-- Marked as WATCHED -->
17:45:08.538 T:5884   DEBUG: CInputManager::OnKey: w (0xf057) pressed, action is ToggleWatched
17:45:08.553 T:7404   DEBUG: CAnnouncementManager - Announcement: OnUpdate from xbmc
17:45:08.553 T:7404   DEBUG: GOT ANNOUNCEMENT, type: 16, from xbmc, message OnUpdate
17:45:08.621 T:5884   DEBUG: Keyboard: scancode: 0x11, sym: 0x0077, unicode: 0x0000, modifier: 0x0
17:45:08.744 T:5884   DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/15/1/?tvshowid=15)
17:45:08.745 T:5884   DEBUG:   ParentPath = [videodb://tvshows/titles/15/1/?tvshowid=15]
17:45:08.757 T:9108   DEBUG: CVideoDatabase::RunQuery took 1 ms for 10 items query: select * from episode_view  WHERE (episode_view.idShow = 15) AND ((episode_view.c12 = 1 or (episode_view.c12 = 0 and (episode_view.c15 = 0 or episode_view.c15 = 1))))
17:45:08.768 T:5884   DEBUG: WindowVideoNav::GetDirectory
<!-- Going BACK to season list -->
17:45:10.267 T:5884   DEBUG: Keyboard: scancode: 0x0e, sym: 0x0008, unicode: 0x0008, modifier: 0x0
17:45:10.309 T:5884   DEBUG: CInputManager::OnKey: backspace (0xf008) pressed, action is Back
17:45:10.309 T:5884   DEBUG: CGUIMediaWindow::GetDirectory (videodb://tvshows/titles/15/)
17:45:10.310 T:5884   DEBUG:   ParentPath = [videodb://tvshows/titles/]
<!-- Did not load from cache and looked up the db-->
17:45:10.349 T:3256   DEBUG: CVideoDatabase::RunQuery took 27 ms for 4 items query: SELECT * FROM season_view  WHERE season_view.idShow = 15
17:45:10.350 T:3256   DEBUG: CVideoDatabase::RunQuery took 1 ms for 0 items query: select * from movie_view join movielinktvshow on movielinktvshow.idMovie=movie_view.idMovie WHERE movielinktvshow.idShow = 15
17:45:10.362 T:5884   DEBUG: WindowVideoNav::GetDirectory

From what i gather at xbmc/windows/GUIMediaWindow.cpp (below fragment), the "items" is not cached when using the built-in database because it returns the data pretty quickly, and that using MySQL it did get cached because it took over 1s to return.
Code:
if ((XbmcThreads::SystemClockMillis() - time) > 1000  && items.CacheToDiscIfSlow())
    items.Save(GetID());

Based on the log snippets above, I see CFileItemList::RemoveDiscCache getting called once to invalidate the cache for the episode list, but not for the parent season list, and when going back to the season list, because Kodi thinks it has a valid cache, it doesn't make a fresh query and uses the previously cached data which has an outdated [un]watchedcount.

Does this happen to you?

PS: I tested this on clean Kodi 17.2 RC1 20170419-661dd08d22, and got the same results.
Reply
#2
Jarvis 16.1 behaves as expected. The difference I see in the logs is that, in Jarvis, there is no Clearing cached fileitems .... Is it possible that Jarvis didn't even cache it, even though the query took 2073ms?

I'm surprised no one else is effected by this. Could it just be that not many use MySQL?
Reply
#3
Tricky, because Kodi #2 has no way to know the value might have changed in the db...
Reply
#4
There is no Kodi #2. It is the same instance of Kodi which is not invalidating its cache that the episode was watched on.
Reply
#5
(2017-05-17, 13:46)Koying Wrote: Tricky, because Kodi #2 has no way to know the value might have changed in the db...
Any chance for a way that magic number of 1 second can be made configurable for let's say Leia with an advanced setting maybe for the SQL DB? On Jarvis everything worked out fine, as it probably never cached to begin with here. 

With a large collection 1 second on the average NAS, RPi or whatever is really not enough to complete the query. It works fine with small DBs naturally or more powerful dedicated machine. But well, not everyone might have it and won't mind a longer delay here.

Some other information being outdated wouldn't be much of a problem.  But watched count is very annoying. You watch an episode, back up and immediately you see that there is something wrong - like you overlooked another episode.

Edit: Never mind, patched it myself and also replaced the views with tables updated by triggers for additional speed up...
Reply
#6
Did you patch the 1 second threshold? Did you by chance do it for ARMV7A? Krypton or Leia?
Reply
#7
is there any update to this? I have this same issue using a single instance with MySQL. The counts don't update and neither do the watched status. The only way to get it to update is to force one by toggling the watch status manually on one episode which triggers a fresh query.
Reply
#8
The problem still exists in Kodi v18.1.
Reply
#9
(2017-11-16, 09:36)Scythe42 Wrote: Edit: Never mind, patched it myself and also replaced the views with tables updated by triggers for additional speed up... 

@Scythe42   I know your reply is old but I'm hoping you are still around.

What did you patch?

I'm seeing this behavior but I don't know when it first started.

running Kodi 18.2
with MySql backend - MariaDB 10.3.7
Reply
#10
I have this same issue.  Been trying to figure it out for a while now.  Today I tested a mysql database located locally on a more powerful machine and everything acts perfectly.  The timeout definately seems to be an issue and wasn't there in Jarvis or below.  

Can we *please* have a customizable timeout for the sql rather than the 1s default?  This is causing a lot of issues for me and others as i've seen this same question posted in many places although the people involved i don't think know it has to do with the 1s database query.  If I could configure that timeout, problem solved.

This also isn't windows specific although it is in the Windows forum.
Reply
#11
@surge919 and @calisro, a patch has already been submitted here: https://github.com/xbmc/xbmc/pull/15916
Reply
#12
(2019-05-02, 05:39)AMoo-Miki Wrote: @surge919 and @calisro, a patch has already been submitted here: https://github.com/xbmc/xbmc/pull/15916

Oh man.  I hope this makes it in.  I was currently trying to figure out a workaround for this without patching and recompiling kodi myself.  Thanks!!
Reply
#13
(2019-05-02, 19:15)calisro Wrote:
(2019-05-02, 05:39)AMoo-Miki Wrote: @surge919 and @calisro, a patch has already been submitted here: https://github.com/xbmc/xbmc/pull/15916

Oh man.  I hope this makes it in.  I was currently trying to figure out a workaround for this without patching and recompiling kodi myself.  Thanks!!


If the patch gets accepted, would it go to both 18 and the 19 alpha?
Reply
#14
(2019-05-11, 04:12)surge919 Wrote:
(2019-05-02, 19:15)calisro Wrote:
(2019-05-02, 05:39)AMoo-Miki Wrote: @surge919 and @calisro, a patch has already been submitted here: https://github.com/xbmc/xbmc/pull/15916

Oh man.  I hope this makes it in.  I was currently trying to figure out a workaround for this without patching and recompiling kodi myself.  Thanks!! 


If the patch gets accepted, would it go to both 18 and the 19 alpha? 

@AMoo-Miki   Any progress getting your patch in Kodi?
Reply
#15
Nah. I just compiled them for my own use.
Reply

Logout Mark Read Team Forum Stats Members Help
Watched count of episodes is not getting updated on seasons-list and titles-list0