[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#459344: closed by Otavio Salvador <otavio@debian.org> (Bug#459344: fixed in apt 0.7.13)



On Sat, 24 May 2008 11:52:56 -0300 Otavio Salvador wrote:

> Francesco Poli <frx@firenze.linux.it> writes:
[...]
> > In other words, unless I am really mistaken, it seems the behavior is
> > just the opposite of the intended one.
> 
> We wait to avoid hitting the mirrors at same time.

Ah, maybe a comment to document this rationale is a good thing to have:
I added it to my patch.

[...]
> We should first wait a random set of time (to avoid massive mirror
> usage) and then do all you did above.

Done, the new behavior is as follows.

If /etc/cron.daily/apt has something (mirror related) to do on the
system, then the script waits for some time (in order to avoid massive
mirror usage) and checks the cache: if the cache cannot be locked, the
script waits for some more time and rechecks.  If the cache is found
locked again, then the script cannot do its job and it exits with
errors.
If /etc/cron.daily/apt has absolutely nothing (mirror related) to do on
the system, it does not need to check whether the cache can be locked,
nor to wait for anything.
At the end, check_size_constraints() is executed anyway.

> 
> > Please consider applying my patch.
> 
> Could you consider my comments above and change it? Then I'll go
> forward and commit your next patch.

New patch attached.

Once again, legal details:
I don't know if my patch constitutes a contribution creative enough to
be copyrighted, but anyway, should it turn out to be actually
copyrighted, I hereby release it under the same terms of
/etc/cron.daily/apt, that is to say, under the terms of the GNU General
Public License (GPL), version 2 or later, as published by the Free
Software Foundation.


-- 
 http://frx.netsons.org/doc/index.html#nanodocs
 The nano-document series is here!
..................................................... Francesco Poli .
 GnuPG key fpr == C979 F34B 27CE 5CD8 DC12  31B5 78F4 279B DD6D FCF4
diff -ruN apt-0.7.13/etc/cron.daily/apt apt-0.7.13-patched/etc/cron.daily/apt
--- apt-0.7.13/etc/cron.daily/apt	2008-05-02 17:14:22.000000000 +0200
+++ apt-0.7.13-patched/etc/cron.daily/apt	2008-05-25 00:34:38.000000000 +0200
@@ -192,19 +192,27 @@
     fi
 fi
 
-# check if we can lock the cache and if the cache is clean
-# There's a reasonable chance that someone is already running an apt
-# frontend that has locked the cache, so exit quietly if it is locked.
-if ! apt-get check -q -q 2>/dev/null; then
-    exit 0
-fi
+# if needed...
+if [ ! $UpdateInterval -eq 0 ] ||
+   [ ! $DownloadUpgradeableInterval -eq 0 ] ||
+   [ ! $UnattendedUpgradeInterval -eq 0 ] ||
+   [ ! $AutocleanInterval -eq 0 ]; then
+
+    # wait random amount of time, to avoid massive mirror usage from
+    # too many systems...
+    random_sleep
+
+    # check if we can lock the cache and if the cache is clean
+    if ! apt-get check -q -q 2>/dev/null; then
+        # wait random amount of time before retrying
+        random_sleep
+        # check again
+        if ! apt-get check -q -q 2>/dev/null; then
+            echo "$0: could not lock the APT cache"
+            exit 1
+        fi
+    fi
 
-# sleep random amount of time
-random_sleep
-
-# check again if we can access the cache
-if ! apt-get check -q -q 2>/dev/null; then
-    exit 1
 fi
 
 UPDATE_STAMP=/var/lib/apt/periodic/update-stamp

Attachment: pgpZcuv_EK8NO.pgp
Description: PGP signature


Reply to: