Anacron prevents shutdown while a job is running. Some packages install long-running jobs.

Bug #1906617 reported by Martin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
anacron (Ubuntu)
New
Undecided
Unassigned
mlocate (Ubuntu)
New
Undecided
Unassigned

Bug Description

I encountered this issue with Anacron and the mlocate package. One of the daily jobs which mlocate installs is a job which runs `updatedb.mlocate` to update its search index. This job goes through the entire filesystem tree, which, as you would expect, can be a fairly long-running process.

When the system shuts down, anacron is sent a SIGUSR1 signal, indicating a graceful shutdown; anacron will exit, but only after all tasks are done. Since one of the daily tasks is long-running, the task likely won't finish within the 90 second window provided by systemd. This means that, fairly often, my shutdowns are delayed by 90 seconds for no good reason; nothing would break if the updatedb.mlocate job was interrupted, and it's going to be interrupted anyways once its 90 seconds are up.

Personally, I think the best solution here is to somehow get Anacron to send a SIGTERM signal to its jobs when the system shuts down. This would delegate responsibility to the job itself. A super critical job which _has_ to complete before shutdown could catch the SIGTERM signal and cleanly exit, while other jobs which don't really care (such as updatedb.mlocate) could just terminate in response to SIGTERM.

The alternative solution would be to ensure that no package will ever install a potentially long-running cron job. I don't know how realistic this is. The mlocate package, for example, would find some other way to periodically trigger an updatedb in a way which doesn't block shutdown (it could, for example, install a systemd timer instead of a cron job).

As a partial solution, one should consider adding some logging to anacron, which makes it print messages like "Waiting for <job name> to shut down..." so that the issue can be debugged. I would've been much less frustrated by this issue over the past few months if the message I saw while shutting down was "anacron: Waiting for job mlocate to terminate..." rather than just "A stop job is running for Run anacron jobs".

I want to clarify that this isn't "just" an issue with mlocate, but an issue with every package which uses cron jobs to run potentially long running jobs. Fixing the mlocate package would treat the particular symptom I'm experiencing, but I'm sure there are many other packages which install potentially long running cron jobs.

ProblemType: Bug
DistroRelease: Ubuntu 20.10
Package: anacron 2.3-29
ProcVersionSignature: Ubuntu 5.8.0-31.33-generic 5.8.17
Uname: Linux 5.8.0-31-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.11-0ubuntu50.2
Architecture: amd64
CasperMD5CheckResult: skip
CurrentDesktop: ubuntu:GNOME
Date: Thu Dec 3 09:01:15 2020
InstallationDate: Installed on 2019-09-14 (445 days ago)
InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
SourcePackage: anacron
UpgradeStatus: Upgraded to groovy on 2020-09-05 (88 days ago)

Revision history for this message
Martin (martid0311) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.