v19 Trying to clean shared SQL database, removing entries that are not on the filesystem
#1
I'm running a shared database setup and want to clean the database removing entries that no longer exist on the filesystem.  I noticed that when I did a video database clean action, my kodi.log would get spammed with 100s of entries for media I no long have on the file system, for example (just cherry picking out 2 examples):
Code:
ERROR <general>: Failed to open(//foo/) opendir call failed with "NFS: Lookup of /foo failed with NFS3ERR_NOENT(-2)"
ERROR <general>: GetDirectory - Error getting nfs://10.9.1.122/srv/nfs4/video/foo/
...
ERROR <general>: GetDirectory - Error getting /mnt/media/video/Misc/youtube/roof_racks/

Is there a guide that offers a method to clean such entries from a shared database?

EDIT: I found this older thread but am interested to know if there is something else out there.  The suggested SQL did not work for me either.
EDIT2: Got the SQL working and updated the wiki.
Need help programming a Streamzap remote?
Reply
#2
(2021-01-31, 14:48)graysky Wrote: I'm running a shared database setup and want to clean the database removing entries that no longer exist on the filesystem.  I noticed that when I did a video database clean action, my kodi.log would get spammed with 100s of entries for media I no long have on the file system, for example (just cherry picking out 2 examples):
 
Code:
ERROR <general>: Failed to open(//foo/) opendir call failed with "NFS: Lookup of /foo failed with NFS3ERR_NOENT(-2)"
ERROR <general>: GetDirectory - Error getting nfs://10.9.1.122/srv/nfs4/video/foo/
...
ERROR <general>: GetDirectory - Error getting /mnt/media/video/Misc/youtube/roof_racks/

Is there a guide that offers a method to clean such entries from a shared database?

EDIT: I found this older thread but am interested to know if there is something else out there.  The suggested SQL did not work for me either.
EDIT2: Got the SQL working and updated the wiki.
Would like to say thank you for your SQL query that I ran on my MariaDB.
Now when performing Clean library within Kodi I'm not getting 2375 lines with "failed with NFS3ERR_NOENT(-2)"
Reply
#3
You're welcome, always glad to share.
Need help programming a Streamzap remote?
Reply
#4
I used to delete a folder using WinSCP so I'm not surprised it was so many of them left in db but today I have deleted a movie via Kodi itself: Manage -> Remove from Library and in both: from library and from disk and.... there is "leftover" in the database:

|_. idFile |_. idPath |_. strFilename |_. playCount |_. lastPlayed |_. dateAdded |
| 8796 | 2975 | The Movie.mkv |  | 2022-04-11 08:52:10 | 2022-04-09 12:32:37 |

Very bad coding in that procedure of "Removing from Library"
Reply
#5
(2022-04-16, 09:06)rafikW Wrote: Very bad coding in that procedure of "Removing from Library"

You'd be surprised what else is still not removed from the video database when deleting a video... It's not so much bad coding as it is a design flaw caused by limited knowledge and/or decisions made from the early days which hasn't been fixed yet.

File folders are not the same as a database, so whenever someone is deleting folders of videos without Kodi knowing, feels to me a bit like having to clean up someone else's mess. Anyway, old entries are not a big problem. The Kodi database size is also only a fraction of what a single UHD video these days is.
Reply
#6
Yes, you are right, MyVideos119 database size is very small (in my case 31 MB) so it is not a main factor for performance for sure.
The problem is that all those leftovers can cause some "unexpected" results. I have faced such.
I have been advised to change provider for my series (https://forum.kodi.tv/showthread.php?tid...pid3094107) from "TMDb TV Shows" to "The TVDB (new)" and once I did that of course it was scraping started.
It failed for few series for the reason I have explained in that thread but two or three series scraping was not possible at all causing strange result like no title was created - just an empty line with number of episodes in the view of TV Shows was visible. Then when I have performed a Kodi cleanup database it was a message that for these series a cleanup was unsuccessful or something. Then I started digging into how to fix that and found out this thread and when a query found more than 2000 "obsolete" lines I was in shock. Anyway once I ran delete query scraping was possible for those few series.
So I think in general queries/triggers for performing delete actions really should be reviewed and updated.
Reply
#7
(2022-04-16, 10:52)rafikW Wrote: I have been advised to change provider for my series
Changing scrapers can open up a whole different can of worms, database-wise... :-|

(2022-04-16, 10:52)rafikW Wrote: So I think in general queries/triggers for performing delete actions really should be reviewed and updated.
Like I already outlined in a different thread, there is more to look at than just the 'files' database table. You could try that Video Database Cleaner addon/tool, and see if that makes a difference. Things on those queries would need to be picked further apart when you only want to delete a single TV episode or a single TV show season. Not impossible, but it needs attention. And because not everything is currently removed properly, rescraping the same video(s) can result into "already in database"-like problems. Also we haven't even mentioned auto-cleaning the biggest clogger: the local thumbnails folder.

The thing is, Kodi has become a beast to code, and we sure could use more developers.
Reply
#8
I have tried Video Database Cleaner add-on.
Only what it did was to delete 4 "orphan" file paths but it did not touch a one movie I have removed from Library and drive using Kodi's action: Manage -> Remove from Library and in both: from library and from disk.
This item still exists in database:
|_. idFile |_. idPath |_. strFilename |_. playCount |_. lastPlayed |_. dateAdded |
| 8796 | 2975 | The Movie.mkv | (NULL)  | 2022-04-11 08:52:10 | 2022-04-09 12:32:37 |

when the following query is invoked:
SELECT *  FROM files WHERE idfile not in (select idfile from episode) and idfile not in (select idfile from movie) and idfile not in (select idfile from musicvideo) ORDER BY `idFile` DESC;

So the main question is: what Manage -> Remove from Library in Kodi is doing?
Reply
#9
(2022-04-16, 13:31)rafikW Wrote: So the main question is: what Manage -> Remove from Library in Kodi is doing?

Probably the following: The files table is a generic table for all videos, local or online like IPTV. Only the entries in movies and/or tvshows & episodes are currently removed.
But I would have to double-check it to be sure. I'm not up-to-date on what is and is not included in the latest versions.
Reply

Logout Mark Read Team Forum Stats Members Help
Trying to clean shared SQL database, removing entries that are not on the filesystem0