Thanks chaley, that is very helpful. I have 3 hypothesis:
- Contention for the remote database file on the device; based on your experience this is now top of my list. I have previously tried allowing for this using two different methods of requesting an exclusive lock on the remote file via the interface library (libimobiledevice). However, I have no idea if this locking request is obeyed on the device; I suspect not because in testing the request always succeeds, whereas I would expect it to sometimes fail (or block) when the device is under load and writing to the file. As you suggest, we probably need Marvin to make a copy of the database, or maybe expose a mutex that both ends can use to synchronise access to the fie.
- Contention for the local database file on the PC. Although there are several Calibre threads which appear in the logs, I can't see any real evidence that they are in contention for the file.
- A bug in the libimobiledevice code that downloads the remote database file. No evidence so far.
I am going to pursue 1 for now.