FS#35603 - [pacman] Pacman doesnt exit cleanly very occasionally

Attached to Project: Pacman
Opened by Jason Russell (jrussell) - Sunday, 02 June 2013, 18:08 GMT
Last edited by Allan McRae (Allan) - Friday, 15 November 2013, 01:06 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To Andrew Gregory (andrewgregory)
Architecture All
Severity Medium
Priority Normal
Reported Version 4.1.2
Due in Version 4.2.0
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:
Pacman sometimes does not exit cleanly when spamming pacman with Ctl+c repetitively.


Additional info:
Forum thread:
https://bbs.archlinux.org/viewtopic.php?pid=1281452
* package version(s)
pacman 4.1.1-1
* config and/or log files etc.


Steps to reproduce:
pacman -Syu (followed by Ctl+C)
pacman -Syu (followed by Ctl+C)
pacman -Syu (followed by Ctl+C)
pacman -Syu (followed by Ctl+C)
Keep going and eventually pacman will say:
:: Synchronizing package databases...
error: failed to update core (unable to lock database)
error: failed to update extra (unable to lock database)
error: failed to update community (unable to lock database)
error: failed to synchronize any databases
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
if you're sure a package manager is not already
running, you can remove /var/lib/pacman/db.lck
This task depends upon

Closed by  Allan McRae (Allan)
Friday, 15 November 2013, 01:06 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit 57090d8c
Comment by Jason Russell (jrussell) - Sunday, 02 June 2013, 18:11 GMT Comment by Jason Russell (jrussell) - Monday, 03 June 2013, 14:26 GMT
log of the problem with --debug attached
   pacman (13.9 KiB)
Comment by Dave Reisner (falconindy) - Monday, 03 June 2013, 14:43 GMT
I never reach your "eventually". The code in question where you're aborting does install its own signal handler, but it restores the default behavior and re-raises the SIGINT, which triggers cleanup in the frontend.

Are you actually able to reproduce this directly via pacman, or does it require invocation via the shell wrapper?
Comment by Jason Russell (jrussell) - Monday, 03 June 2013, 14:50 GMT
Yes, the "pacman" file I attached is directly from pacman.

I did it about 15 times, then I got the db.lock warning. Sometimes it happens sooner, and sometimes my fingers get sore and it won't happen.
Comment by Jason Russell (jrussell) - Wednesday, 19 June 2013, 14:46 GMT
Anyone else managed to reproduce this?
Comment by Andrew Gregory (andrewgregory) - Thursday, 20 June 2013, 04:43 GMT
I believe I've found the problem, but I'm not sure how to fix it. In _alpm_handle_lock there is a brief window between db.lck being created and the stream being saved to the handle. If the user interrupts in that window, db.lck will not be deleted. We can shrink the window by saving the stream directly to the handle instead of using an intermediate variable, but I don't know a way to close the window altogether.

Loading...