apt-mirror won't delete it's lock-file on exit

Bug #424462 reported by JuRiJ on 2009-09-04
This bug affects 14 people
Affects Status Importance Assigned to Milestone
apt-mirror (Ubuntu)
Brandon Holtsclaw

Bug Description

Binary package hint: apt-mirror

affected package:
apt-mirror 0.4.6-0ubuntu2

use case:
install apt-mirror

run as root:
su - apt-mirror -c apt-mirror

hit "Ctrl + c" to abort the command

run again:
su - apt-mirror -c apt-mirror

and you get this output:
apt-mirror is already running, exiting at /usr/bin/apt-mirror line 187.

the case for this error message is that file:
was not deleted on apt-mirror exit.
If you delete apt-mirror.lock file, then apt-mirror will run OK, but you have to delete the file every time apt-mirror finishes it's job.

possible bug introduction was in apt-mirror (0.4.6-0ubuntu1) karmic, because file locking was added:
  * added file locking, more than one apt-mirror instance cant run at once

JuRiJ (juraj-kvasnica) on 2009-09-04
description: updated
Fernando (correiodofernando) wrote :

Eu também tive esse problema. Somente apagando manualmente o Lock o apt-mirror volta a funcionar.

tags: added: apt-mirror karmic
tags: added: 187 already line running
Tony Yarusso (tonyyarusso) wrote :

Confirmed exactly as described on Karmic beta. (Manually deleting the lockfile is necessary to run it again.)

Changed in apt-mirror (Ubuntu):
status: New → Confirmed
Tony Mugan (tmugan) wrote :

Confirmed exactly as detailed above with latest patches to Karmic (20091018)

Tony Mugan (tmugan) wrote :

My comment above is not entirely accurate.
Once I manually deleted the file apt-mirror.lock (I do not have it the default location of /var/spool/apt-mirror/var/apt-mirror.lock), then apt-mirror continued to work.

However, the stray lock file would have caused the issue above to continue under the current version.
Perhaps, a command line parameter e.g. --reset-lock could be added which the locking error would inform the user about?

Tony Yarusso (tonyyarusso) wrote :

Note - I only experienced this when aborting the process with Ctrl-C or similar. If apt-mirror exited gracefully by *finishing* it's download the lock was properly removed.

Steve Lilley (steveglilley) wrote :

I have just had this same bug occur for me I had successfully mirrored the security and updates repositories and tried to do the repositories of backports and Karmic proposed. I stopped it during its process and changed one item. And tried to rerun sudo apt-mirror but it gave me an error "apt-mirror is already running, exiting at /usr/bin/apt-mirror line 187". I went to the directory you mentioned /var/spool/apt-mirror/var/apt-mirror.lock to delete apt-mirror.lock but it wasn't there. Got any suggestions as what I must do to fix this problem and get apt-mirror to work again. Worst option is uninstall mirror and reinstall and see if it rectifies the problem

Steve Lilley (steveglilley) wrote :

I tried the uninstall and reinstall using synapitc but I get the same error. Any suggestions about what I might do to change this. Remembering there isn't any file at /var/spool/apt-mirror/var/apt-mirror.lock

Steve Lilley (steveglilley) wrote :

A friend of mine solved my problem. I had changed the location of my /var path in my mirror script and it was in the new directory. I found the offending file and deleted it and now it works

jevangelo (jevangelo) wrote :

if you wait ~30 seconds after it is finished, the clean.sh script info appears, and the lock file goes away.

triki (triki42o) wrote :

I had the same issue, my lock file was not in /var/lock/apt-mirror, the apt-mirror was missing from /var/lock all together.
I found my lock file in /var/spool/apt-mirror/var/apt-mirror.lock. Once I removed the lock file apt-mirror was able to start once again.

Carl Strickler (cstrickler) wrote :

The problem is that apt-mirror is not handling SIGINT, SIGHUP, or SIGTERM correctly thereby leaving a stale lock file around and does not actually check for a running process before reporting that one is already running. It should trap these and clean up before exiting or at the very least report something such as "apt-mirror is dead, but lockfile /path/to/lockfile/apt-mirror.lock exists: exiting" instead of just reporting that the process is already running.

You will not see this behavior if the process completes normally.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt-mirror - 0.4.6-0ubuntu4

apt-mirror (0.4.6-0ubuntu4) lucid; urgency=low

  * Add 03-clean-lock-file.patch to delete the lock file on every exit
    (LP: #424462).
  * Update default config to mention lucid (LP: #551605).
 -- Benjamin Drung <email address hidden> Thu, 15 Apr 2010 23:20:51 +0200

Changed in apt-mirror (Ubuntu):
status: Confirmed → Fix Released
MarianoAbsatz (el-baby) wrote :

any chance that 0.4.6-0-ubuntu4 appears on karmic? (or karmic-updates or karmic-backports?)
Current 0.4.6-0ubuntu3 karmic package still has this bug.

Benjamin Drung (bdrung) wrote :

Your wish will be granted. I uploaded the attached patch to karmic-proposed. You can test it from there once it is approved.

Accepted apt-mirror into karmic-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in apt-mirror (Ubuntu Karmic):
status: New → Fix Committed
tags: added: verification-needed
chrone (chrone81) wrote :

i can confirm this bug is still exist in lucid lynx. just happened today and found this thread in ubuntuforums.org. manually deleting the apt-mirror.lock in /var/spool/apt-mirror-/var fixed this bug.

Benjamin Drung (bdrung) wrote :

@chrone: version 0.4.6-0ubuntu4 and later in lucid shouldn't have this bug. Can you reproduce this problem?

limaxray (matt-limaxray) wrote :

I can also confirm this bug still exists in 0.4.7 on lucid, although it is partially fixed when handling signals (albeit not really, more on that later).

First, the lock file still remains after an ungraceful exit. For example - adding an invalid repository to mirror.list will cause apt-mirror to fail and exit without deleting the lock. The lock will then need to be manually deleted before apt-mirror can run again. This is a problem when mirroring an unreliable repository since it will break automatic mirroring if the source repo is down when apt-mirror is run. (This should perhaps also be a separate bug since, IMHO, a single broken repo shouldn't cause the entire mirror process to fail. Or is this a feature?)

Try this:
1) Add bogus repo to you mirror config (ie 'deb http://bogusrepository.com/ubuntu lucid main')
2) Run apt-mirror
3) Wait for apt-mirror to fail and exit
4) Run apt-mirror again
5) Note aforementioned error

Second, I can no longer kill apt-mirror with a sigint, sighup, or sigterm - these signals are now seemingly ignored. Upon further inspection, It looks like it is catching the signals, deleting the lock, but fails to actually exit. If a sigint is given during a download stage, it will stop downloading and continue on to the next stage like nothing happened. If sigint is given during the 'proceed indexes' stage, nothing seems to happen other than the lock being deleted.

Try this:
1) Run apt-mirror (with valid config)
2) Press ctrl+c immediately
3) Note index download completes in record time, and apt-mirror proceeds to process indexes
4) While apt-mirror continues, in another terminal, run 'ls /var/spool/apt-mirror/var/apt-mirror.lock'
5) Note no such file error as apt-mirror continues to run in other terminal
6) While apt-mirror continues to process indexes, press ctrl-c again
7) Note apt-mirror continues to process indexes

So yes, the bug still exists in 0.4.7 but with an additional regression.

Brandon Holtsclaw (imbrandon) wrote :

OK, I have reconfirmed this still affects 0.4.8 and am working on a patch now.

Changed in apt-mirror (Ubuntu Karmic):
status: Fix Committed → Confirmed
Changed in apt-mirror (Ubuntu):
status: Fix Released → Confirmed
assignee: nobody → Brandon Holtsclaw (imbrandon)
Changed in apt-mirror (Ubuntu Karmic):
assignee: nobody → Brandon Holtsclaw (imbrandon)
importance: Undecided → Medium
Changed in apt-mirror (Ubuntu):
importance: Undecided → Medium
Martin Pitt (pitti) wrote :

Current karmic-proposed package removed.

Micah Gersten (micahg) wrote :

Karmic is EOL, so marking this task won't fix.

Changed in apt-mirror (Ubuntu Karmic):
assignee: Brandon Holtsclaw (imbrandon) → nobody
status: Confirmed → Won't Fix
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apt-mirror - 0.4.8-5

apt-mirror (0.4.8-5) unstable; urgency=low

  * Improve lock file handling to avoid false "apt-mirror is already running"
    messages. Thanks to Ivan Borzenkov <email address hidden>
    (Closes: #589167, LP: #424462)
  * Create directories after config is parsed.
    Thanks to Rob Verduijn (Closes: #619353, LP: #727011)
  * Support armhf, kfreebsd-* and s390x arch. (Closes: #644630)

 -- Benjamin Drung <email address hidden> Sat, 28 Jan 2012 14:27:12 +0100

Changed in apt-mirror (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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