Created attachment 75836 [details] [review] 0001-Restart-memcached-after-koha-remove-if-needed.patch After running koha-remove, stale data remains in within the memcached server. Say if an instance is deleted then recreated immediately, changed data such as database credentials isn't loaded into the cache, resulting in strange, difficult to troubleshoot problems. The solution would be to flush memcached cache at the end of koha-remove. The most straightforward method to do this is simply restart the service. See attached patch.
Note for later, see also: https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=75384
Using a function like flush_cache() would indeed be better than restarting the service.
Hi, Is there a test plan for this? Or do changes need to be made to align with the previous comments?
Comment on attachment 75836 [details] [review] 0001-Restart-memcached-after-koha-remove-if-needed.patch Review of attachment 75836 [details] [review]: ----------------------------------------------------------------- ::: debian/scripts/koha-remove @@ +139,5 @@ > done > > +if [ -e /etc/koha/koha-sites.conf ] > +then > + . /etc/koha/koha-sites.conf What is the purpose of this?
The purpose is to load the USE_MEMCACHED variable into the environment from koha-sites.conf.
I dont like "memcached restart" for this. We have many Koha instances on the same server, all using the same memcached instance. We also have SessionStorage = memcached. This means that if we remove an instance, memcached will be restarted and every user of every Koha instance will be logged out. If it is possible to just flush the cash of the removed site that would be much better.
Looking at this a bit more it looks like there is no easy way to clear/flush memcached for only one namespace (since memcached does not really have a concept of namespaces) or Koha site. Unless there is some magic in Koha::Cache et al that goes way above my head. As far as I can make out the problem is there is no way to list all keys in mamcahed so they could all be deleted. To get around this we would have to register all the keys we use somewhere and then loop over and delete them. That could perhaps be doable, though?
See comment 1 and the patch I linked to.
We now have misc/bin/clear_cache.pl. That should be quite easy to implement a call to this script to clean the cache correctly (and avoid restarting memcached).