[<a href="mailto:root@sirius" target="_new">root@sirius</a> root]# rpm -q apt rpm apt-0.5.4cnc9-alt4 rpm-4.0.4-alt12 When doing \"apt-get install XXX\" and the required packages are on more than one CD-ROM (so disk changing is necessary), the operation hangs after fetching all packages. I have reproduced this on my system (which is only partially upgraded from Sisyphus, and some packages are from Master 2.0 CDs): [<a href="mailto:root@sirius" target="_new">root@sirius</a> root]# apt-get install libpwlib-devel Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: libpwlib The following NEW packages will be installed: libpwlib libpwlib-devel 0 packages upgraded, 2 newly installed, 0 removed and 0 not upgraded. Need to get 0B/1312kB of archives. After unpacking 4459kB will be used. Do you want to continue? [Y/n] Media Change: Please insert the disc labeled \'ALT Linux Master CD 1\' in the drive \'/mnt/cdrom/\' and press enter Get:1 <a href="cdrom://ALT">cdrom://ALT</a> Linux Master CD 1 Mandrake/Master libpwlib 1.2.12-alt1 [918kB] Fetched 918kB in 16s (54.1kB/s) Media Change: Please insert the disc labeled \'ALT Linux Master CD 3\' in the drive \'/mnt/cdrom/\' and press enter Get:1 <a href="cdrom://ALT">cdrom://ALT</a> Linux Master CD 3 Mandrake/Master libpwlib-devel 1.2.12-alt1 [394kB] Fetched 394kB in 25s (15.3kB/s) Executing RPM (/bin/rpm -Uvh --fancypercent --oldpackage)... At this point the process hangs until killed by ^C. Further examination from another terminal gives: [<a href="mailto:root@sirius" target="_new">root@sirius</a> root]# lsof /var/lib/rpm/Packages COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME apt-get 3602 root 4uW REG 3,11 15044608 112 /var/lib/rpm/Packages rpm 3609 root 3u REG 3,11 15044608 112 /var/lib/rpm/Packages [<a href="mailto:root@sirius" target="_new">root@sirius</a> root]# strace -v -p 3602 wait4(3609, <unfinished ...> [<a href="mailto:root@sirius" target="_new">root@sirius</a> root]# strace -v -p 3609 fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0} <unfinished ...> This shows that rpm is waiting for the database lock, but apt-get did not release it before running rpm, therefore a deadlock happens. The problem appears only when the packages are fetched from CD-ROM, and more than one CD-ROM disk is used (installation from local files, FTP, or from CD-ROM when only one disk is needed work without this happening). Repeating the failed apt-get command after killing the hung one with ^C also works (because this time all package files are in the cache). I have tracked down the problem to a bug in the apt-get code (apt-0.5.4cnc9/cmdline/apt-get.cc, InstallPackages()). The problem is that the body of the loop at the end of this function (with the \"Run it\" comment) is executed several times when multiple CD-ROMs are used. Therefore _system->Lock() at the end of this loop is executed on each pass other than the last, and _system->UnLock() before PM->DoInstall() does not really unlock the database, because the lock count remains greater than zero. I suggest to move this Lock() call earlier, so that it is called only when UnLock() was called before. The difference will be that Fetcher.Shutdown() and PM->GetArchives() will now be called with the lock held, but these operations should work irrespective of the lock state. The patch is attached (tested with apt-0.5.4cnc9-alt4; -alt6 does not seem to have any changes in the related code - did not test it actually). --- ---
Maybe set lock right after PM->DoInstall()?
Maybe - I did not try this (something might depend on the fact that rpmdb is unlocked on the successfull return from InstallPackages(). (apt-get code is not very pretty - e.g., look what they do with CmdL nearby...)
Maybe bring this topic to apt-rpm@ ?
Applied this patch in apt-0.5.4cnc9-alt7
Should be fixed in apt-0.5.4cnc9-alt7 and later.