User tomaszg and I have put some time into investigating the supposed tags cache corruption problem for which the accepted wisdom has been to delete the MOC tags cache. It has actually turned out to be a problem with stale database locks left over after a previous server crash, and I have today committed a patch (r2492) which I believe fixes it.
- The client freezes.
- The server continues playing but does not respond to commands.
- Neither the server nor the client can be shut down gracefully.
- The client's status message indicates a server communication is in progress, usually relating to tags or playlist.
- The command db_stat -h ~/.moc/cache shows the same WRITE lock being HELD and WAITed for on the same audio file.
- This does not change significantly after the server is terminated.
- When the server is terminated the client also terminates with a fatal error about being unable to receive a value from the server.
- Setting the 'TagsCacheSize' option very low significantly increases the frequency of the problem appearing.
- At some point the server has died while holding a database lock.
- Eventually the server attempts to acquire the lock and waits forever.
- Because it's blocked on the lock it cannot service new requests.
- The client sends a request and waits forever for the response.
- kill -9 $(cat ~/.moc/pid)
- db_recover -h ~/.moc/cache
- rm -f ~/.moc/cache/log.*
(Note that step 2 will create a 10MB log file. Step 3 deletes it, but you will still need to have sufficient space in your filesystem.)
MOC no longer uses files (~/.moc/cache/__db.*) to back the memory in which locks are held. So when the MOC server crashes, any locks it is holding disappear along with the process's memory. This works because MOC uses single-process (though multi-threaded) access to the database holding the tags cache and it appears that losing the file-backed memory does not endanger the database's structural integrity.
node/825 (this is a textbook example of this problem)
node/599 (here the segfault is the triggering event)