Bug 205013 - Interaction between anacron + vixie-cron causes jobs to be run twice
Interaction between anacron + vixie-cron causes jobs to be run twice
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: anacron (Show other bugs)
5
All Linux
medium Severity high
: ---
: ---
Assigned To: Marcela Mašláňová
Brock Organ
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-02 05:43 EDT by David Anderson
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version: anacron-2.3-41.fc5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-07-04 10:00:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
run-parts script (887 bytes, text/plain)
2006-11-28 10:21 EST, Marcela Mašláňová
no flags Details

  None (edit)
Description David Anderson 2006-09-02 05:43:57 EDT
Description of problem:

On Tuesday 29th August, I turned on my machine at 02:49. Log entries 
(/var/log/cron):
Aug 29 02:49:05 shed crond[1554]: (CRON) STARTUP (V5.0)
Aug 29 02:49:07 shed anacron[1592]: Anacron 2.3 started on 2006-08-29
Aug 29 02:49:07 shed anacron[1592]: Will run job `cron.daily' in 65 min.
Aug 29 02:49:07 shed anacron[1592]: Jobs will be executed sequentially

Then, at 03:54, as promised, anacron ran the cron jobs:
Aug 29 03:54:07 shed anacron[1592]: Job `cron.daily' started
Aug 29 03:54:08 shed anacron[2178]: Cannot run - another anacron process is 
already running.: Resource deadlock avoided

I suppose that second line is anacron running itself from the daily cron job. 
The jobs definitely ran, as shown by what turned up in my mailbox:

From root@shed Tue Aug 29 03:54:24 2006
<snip>
 ################### Logwatch 7.2.1 (01/18/06) ####################
        Processing Initiated: Tue Aug 29 03:54:19 2006
        Date Range Processed: yesterday
                              ( 2006-Aug-28 )
                              Period is day.
      Detail Level of Output: 0
              Type of Output: unformatted
           Logfiles for Host: shed
  ##################################################################
<snip>

However, before those cron jobs finished, cron itself began its daily run:
Aug 29 04:01:01 shed crond[7697]: (root) CMD (run-parts /etc/cron.hourly)
Aug 29 04:02:01 shed crond[7751]: (root) CMD (run-parts /etc/cron.daily)
Aug 29 04:02:02 shed anacron[7756]: Cannot run - another anacron process is 
already running.: Resource deadlock avoided

And so I got another identical e-mail, as the same jobs were run:

From root@shed Tue Aug 29 04:02:24 2006
<snip>
 ################### Logwatch 7.2.1 (01/18/06) ####################
        Processing Initiated: Tue Aug 29 04:02:15 2006
        Date Range Processed: yesterday
                              ( 2006-Aug-28 )
                              Period is day.
      Detail Level of Output: 0
              Type of Output: unformatted
           Logfiles for Host: shed
  ##################################################################
<snip>


Then finally, the original anacron job terminates. It took so long because it 
was running the monstrous prelink job:
Aug 29 04:24:06 shed anacron[1592]: Job `cron.daily' terminated (mailing 
output)
Aug 29 04:24:08 shed anacron[1592]: Normal exit (1 jobs run)


Hence it seems that, if an anacron run starts before the cron.daily run and 
doesn't finish before it, then cron jobs get run twice. That seems an obvious, 
potentially serious (depending on whats in the cron jobs) bug. Should this bug 
be made an FC6 blocker?

Version-Release number of selected component (if applicable):
[david@shed ~]$ rpm -q anacron vixie-cron
anacron-2.3-39.fc5
vixie-cron-4.1-56.fc5


How reproducible: Haven't tried, but can't see why it won't be every time.


Steps to Reproduce:
1. Reboot machine at appropriate time of day so that anacron runs just before 
the cron.daily run at 4pm.
  
Actual results:
Cron jobs run twice.

Expected results:
No cron job runs twice.
Comment 1 David Anderson 2006-09-02 05:49:29 EDT
Actually, rather than the cause being that its because anacron hasn't yet 
finished, maybe this happens every time you reboot your machine in between 
midnight and the daily cron run at 4am?
Comment 2 Marcela Mašláňová 2006-09-19 09:59:52 EDT
Hello,
it's same problem as #205747, don't you think? I pushed anacron-2.3-40.fc5 
update today. It will be on mirrors in a few days, please try it and let me 
know, if it's everything ok now.
Comment 3 Marcela Mašláňová 2006-09-29 09:30:20 EDT
Could be solved in #anacron-2.3-41.fc5
Comment 4 David Anderson 2006-10-06 16:13:42 EDT
Looks completely unlike 205747 - can you explain what you mean?
Comment 5 David Anderson 2006-10-09 11:40:57 EDT
I've reopened this bug, as there's no possible way that the fdclose patch 
could have anything to do with it.
Comment 6 Marcela Mašláňová 2006-10-11 10:35:32 EDT
Sorry, mistake. 
I'll try to reproduce and find out how is this possible.
Comment 7 Marcela Mašláňová 2006-11-07 10:01:46 EST
>Hence it seems that, if an anacron run starts before the cron.daily run and 
>doesn't finish before it, then cron jobs get run twice.

Anacron couldn't run before cron.daily, because anacron is runed by cron from
cron.daily. I couldn't reproduce double running the same job.

>It took so long because it was running the monstrous prelink job:

Prelink could be small, fast job. I found something about huge prelink, but it
wasn't done by cron.

Could you please write howto reproduce in more detail?
Comment 8 David Anderson 2006-11-07 16:17:01 EST
Try running a LiveCD on your machine and adjusting the clock to 02:47 tomorrow 
morning, and then rebooting - and then leave it until some time after 4am when 
the anacron and daily cron jobs will have had time to do their thing.

As I say, I got this happening when I booted at 02:49 one morning.
Comment 9 David Anderson 2006-11-07 16:18:18 EST
In case I wasn't clear, anacron ran as part of the clean-up that begins 65 
minutes after you boot - not as part of the daily cron.
Comment 10 Marcela Mašláňová 2006-11-28 10:21:11 EST
Created attachment 142293 [details]
run-parts script

run-parts script for testing
Comment 11 Marcela Mašláňová 2006-11-28 10:23:33 EST
Ha, I'd reproduced it. You need newest anacron(I have anacron-2.3-41.fc6), which
has pid file. I changed run-parts script from crontabs. 
If you want, you can test it. I'll be testing it before push to update.
run-parts are in /usr/bin/
Comment 12 David Anderson 2006-11-28 15:50:41 EST
My head hurts trying to understand what side-effects that change might have! 
What's the rationale behind it?
Comment 13 Marcela Mašláňová 2007-07-04 10:00:34 EDT
Please reopen this bug against F7 if it still exists there. I didn't reproduce
it in F-7.

Note You need to log in before you can comment on or make changes to this bug.