2019-08-06, 15:25
After some testing, here is an explanation I have found for the persistent error "Failed to start common cache. Check log" when starting Kodi.
Enabling common cache service debugging, this error is logged in Windows:
So there is a conflict with common cache trying to bind its service to a local port that is already in use. Now let us try to find out why this is happening.
If you had another running program binding a service to the same local port as common cache uses (by default 59994 in Windows) then this error would be logic, but that is not the common scenario. The usual cause is that common cache service did not properly close last time you stopped Kodi.
But when you close Kodi all its running services are stopped and their service sockets are closed, so... again, why is this happening?
Certainly if you close Kodi normally it closes all its services and kills all its child processes. But if instead of closing it you kill the Kodi process (with Windows task manager, task killer application, or something alike), then Kodi closes everything it can but does not necessarily kill plugin opened processes that run separately as a daemon. Those daemon plugins will not be properly closed, and if they eventually started the common cache service, that service socket will still be in use next time you run Kodi.
So to reproduce this error you should:
1. Enable a plugin that runs as a daemon and uses/starts common cache (like references to banned addon (wiki) junk removed ...).
2. Kill the Kodi process with task manager.
3. Do not kill the plugin daemon process.
4. Start Kodi again.
When the daemon runs again and tries to start common cache service, it will find that the common cache service socket is already in use by the previous running instance of the daemon and thus it fails to start common cache.
You can check that if you also kill the plugin daemon process then the error does not appear when starting Kodi again. Also, if you close Kodi the normal way then it politely kills the plugin daemon process and the service is properly closed, so the error does not appear either.
This was tested only in Windows, with Kodi 18.3 and Common cache plugin 2.5.10. But I am afraid this could also happen when Kodi is forced to close by Android energy or memory savers.
I hope this information helps somebody to find a way to avoid this error happening in his/her specific scenario.
By the way, why are there plugins that need to run as daemon processes? Would not be enough for them to run as Kodi child processes?
Mod edit to remove references to banned addons (wiki).
Enabling common cache service debugging, this error is logged in Windows:
log:NOTICE: [StorageServer-2.5.4] '_sock_init' : 'Done: ('127.0.0.1', 59994)'
NOTICE: [StorageServer-2.5.4] '_startDB' : 'sql3 - C:\Users\<USERNAME>\AppData\Roaming\Kodi\cache\commoncache.db'
NOTICE: [StorageServer-2.5.4] 'run' : 'Exception: error(10048, 'Only one usage of each socket address (protocol/network address/port) is normally permitted.')'
So there is a conflict with common cache trying to bind its service to a local port that is already in use. Now let us try to find out why this is happening.
If you had another running program binding a service to the same local port as common cache uses (by default 59994 in Windows) then this error would be logic, but that is not the common scenario. The usual cause is that common cache service did not properly close last time you stopped Kodi.
But when you close Kodi all its running services are stopped and their service sockets are closed, so... again, why is this happening?
Certainly if you close Kodi normally it closes all its services and kills all its child processes. But if instead of closing it you kill the Kodi process (with Windows task manager, task killer application, or something alike), then Kodi closes everything it can but does not necessarily kill plugin opened processes that run separately as a daemon. Those daemon plugins will not be properly closed, and if they eventually started the common cache service, that service socket will still be in use next time you run Kodi.
So to reproduce this error you should:
1. Enable a plugin that runs as a daemon and uses/starts common cache (like references to banned addon (wiki) junk removed ...).
2. Kill the Kodi process with task manager.
3. Do not kill the plugin daemon process.
4. Start Kodi again.
When the daemon runs again and tries to start common cache service, it will find that the common cache service socket is already in use by the previous running instance of the daemon and thus it fails to start common cache.
You can check that if you also kill the plugin daemon process then the error does not appear when starting Kodi again. Also, if you close Kodi the normal way then it politely kills the plugin daemon process and the service is properly closed, so the error does not appear either.
This was tested only in Windows, with Kodi 18.3 and Common cache plugin 2.5.10. But I am afraid this could also happen when Kodi is forced to close by Android energy or memory savers.
I hope this information helps somebody to find a way to avoid this error happening in his/her specific scenario.
By the way, why are there plugins that need to run as daemon processes? Would not be enough for them to run as Kodi child processes?
Mod edit to remove references to banned addons (wiki).