Bug 36492

Summary: memcached: Double pid file may cause memcached to not start up
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Marcel de Rooy 2024-04-02 13:51:20 UTC
Sometimes at container restart the memcached process does not come up for some reason. (Running Debian11.)

In the logs I found:
Could not open the pid file /var/run/memcached/memcached.pid.tmp for writing: No such file or directory

The *funny* thing is that the init.d script refers to /var/run/memcached.pid but the /etc/memcached.conf file contains:
-P /var/run/memcached/memcached.pid

In my case this folder does not exist in /var/run.

Seems like a Debian problem, but directly affects daily Koha operation. Solving it temporarily by a sed on memcached.conf. Maybe this workaround may also help others.
Comment 1 Marcel de Rooy 2024-04-03 11:50:39 UTC
Changing the conf file is not the complete answer. Actually this fix from https://github.com/saz/puppet-memcached/issues/27 does it the other way around:

mkdir /var/run/memcached
chown memcache:memcache /var/run/memcached
memcached.conf should (still) contain: -P /var/run/memcached/memcached.pid

What happens now when stopping and starting? (Note that /etc/init.d/memcached stop does not work! Try: start-stop-daemon --stop --quiet --oknodo --retry 5 --name memcached)

In var/run:
-rw-r--r-- 1 root        root           5 Apr  3 13:24 memcached.pid
In var/run/memcached:
-rw-r--r-- 1 memcache memcache 6 Apr  3 13:24 memcached.pid

Both files contain the same PID but the latter one contains a newline too.
A new stop/start will create new pid files. No warnings anymore.
Comment 2 Marcel de Rooy 2024-11-07 10:54:04 UTC
This confusing situation still exists under Debian 12 btw.
Comment 3 Marcel de Rooy 2025-05-19 08:14:30 UTC
Still an issue as of today.
Comment 4 Marcel de Rooy 2025-05-19 09:14:04 UTC
@Tomas: Does KTD do something to prevent this from happening? Like removing BOTH pid files? /var/run/memcached.pid as well as /var/run/memcached/memcached.pid