https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40901

--- Comment #1 from Tristin Stagg <[email protected]> ---
Currently, the koha-common.service systemd unit is just a wrapper around
/etc/init.d/koha-common, which internally uses Koha’s shell wrappers and the
daemon command to launch all Koha subcomponents (Plack, Zebra, Z39.50
responder, SIP2 server, background workers, indexers, etc.) under a single
systemd service.

This has several problems:

1) No process isolation: All subcomponents for all Koha instances are children
of koha-common.service.

2) OOM-killer issues: When the system is under memory pressure, the Linux OOM
killer can indiscriminately kill any Koha sub-daemon. In our environment, we’ve
seen background workers or Plack workers being killed silently.

3) Poor observability: systemctl status koha-common shows a giant mixed tree of
processes. It is difficult to identify which component is misbehaving or using
excessive resources.

4) systemd integration is broken: Features like per-service cgroup limits
(MemoryMax=, CPUQuota=), restart policies, logging (journalctl -u), and failure
detection cannot be used at the component level.

Environment:

- Debian 10, 11, 12
- Koha version: At least 24.11-25.05

Steps to Reproduce:

1) Install Koha via Debian packages.
2) Start an instance, e.g. koha-create --create-db mainlib.
3) Run systemctl status koha-common.service.
4) Observe that all daemons (Plack, Zebra, workers, indexers, Z39.50, etc.) run
under the single koha-common.service process tree.

Observed Behavior:
All Koha daemons for all instances run under one service. For example:

● koha-common.service - Start required services for each Koha instance
   Loaded: loaded (/etc/init.d/koha-common; enabled)
   Active: active (running)
   CGroup: /system.slice/koha-common.service
           ├─ starman master …
           ├─ starman worker …
           ├─ zebra …
           ├─ background_jobs_worker.pl …
           ├─ es_indexer_daemon.pl …
           └─ etc.

When memory pressure occurs, OOM-killer may kill any of these, and systemd does
not restart them because they are just sub-processes of koha-common.

Expected Behavior:

Each Koha subcomponent (Plack, Zebra, workers, indexers, Z39.50, SIP2, etc.)
should run as its own systemd unit, ideally with instance scoping. For example:

- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]

And koha-common.service could be a meta unit (or target) that pulls in all the
per-instance units.

This would allow:

- Proper systemd supervision of each daemon
- Restart policies if one crashes
- Independent resource limits
- Better logging and observability

Why this matters:
Right now, Koha administrators lose visibility and control of critical
services. In production environments, a single rogue process can consume
memory, trigger the OOM-killer, and kill unrelated Koha daemons, taking down
parts of the system silently. This design makes Koha fragile on modern Linux
systems.

Suggested Fix:

1) Replace the init.d style management with native systemd unit files for each
Koha component.
2) Use templated units for instance support ([email protected], etc.).
3) Have koha-common.service or koha.target depend on these per-instance units.
4) This would align Koha with best practices for systemd-based services and
improve stability, observability, and maintainability in production.

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to