Closed metellius closed 8 years ago
Haven't been able to reproduce in gdb yet due to the race conditions.
Does it look like some kind of concurrency problem around the database to you too?
After looking at the code now for a few moments, yes. looks like it could be about get/putThumbnail getting called from multiple threads simultanously (this is certainly the case after loading this project with lots of clips wanting thumbnails). I'll add some mutexes and test the theory.
Well, adding a mutex for get/put thumbnail seems to fix it, but I think we might need more engineering to do this in accordance with the docs: http://doc.qt.io/qt-5/threads-modules.html says
Threads and the SQL Module
A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported.
Maybe there needs to be a database worker thread that takes care of the database. Feels overly complicated though; to be honest I'm wondering if we even need a database for this? For comparison the xdg thumbnail specification that most linux file browsers like nautlius and dolphin use for storing thumbnails simply says to write into files with hash-filenames in ~/.thumbnails...
A database is used because it is a cache to prevent consuming disk space without limit and because there is no cross-platform way to sort a directory by access time.
hmm. yes, i forgot that it's about atime and not mtime. I'm looking at a solution that makes Database a QThread and uses waitconditions in order to keep the exact same api, but use a worker thread internally.
Seems to have something to do with the thumbnail database.