Bug 20884 - Stale data remaining in cache after koha-remove
Summary: Stale data remaining in cache after koha-remove
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jerome Charaoui
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-05 20:09 UTC by Jerome Charaoui
Modified: 2020-05-13 13:40 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
0001-Restart-memcached-after-koha-remove-if-needed.patch (983 bytes, patch)
2018-06-05 20:09 UTC, Jerome Charaoui
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Charaoui 2018-06-05 20:09:48 UTC
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.
Comment 1 Jonathan Druart 2018-06-05 20:14:56 UTC
Note for later, see also: https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=75384
Comment 2 Jerome Charaoui 2018-06-05 20:24:44 UTC
Using a function like flush_cache() would indeed be better than restarting the service.
Comment 3 Hayley Pelham 2019-04-17 03:58:15 UTC
Hi,

Is there a test plan for this? Or do changes need to be made to align with the previous comments?
Comment 4 Mark Tompsett 2019-06-17 15:49:46 UTC
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?
Comment 5 Jerome Charaoui 2019-06-17 15:54:35 UTC
The purpose is to load the USE_MEMCACHED variable into the environment from koha-sites.conf.
Comment 6 Magnus Enger 2019-10-03 14:10:23 UTC
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.
Comment 7 Magnus Enger 2019-10-03 15:00:16 UTC
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?
Comment 8 Jonathan Druart 2019-10-14 13:21:38 UTC
See comment 1 and the patch I linked to.
Comment 9 Jonathan Druart 2020-05-13 13:40:01 UTC
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).