PackageKit / PackageKit

A D-BUS abstraction layer that allows the user to manage packages in a secure way using a cross-distro, cross-architecture API.
https://www.freedesktop.org/software/PackageKit/
GNU General Public License v2.0
257 stars 163 forks source link

pkcon hangs during update #522

Open Krzmbrzl opened 2 years ago

Krzmbrzl commented 2 years ago

SUMMARY

Given that Discover now forces me to perform offline-updates, I wanted to install updates via apt upgrade which told me to use pkcon update instead.

Using that however has about a 30-50% chance of getting stuck during the process. It usually happens during the "Running" phase were it will just hang in there indefinitely (until I Ctrl+C out of it). Every once in a while it also gets stuck in the "Installing" phase (usually around 80%). Ctrl+C'ing out of it and then re-running pkcon update then reports that there are no packages that need updating which kinda suggests to me that it is only the "UI" that gets stuck while the update has completed in the background.

STEPS TO REPRODUCE

  1. Run pkcon update
  2. See that it gets stuck

SOFTWARE/OS VERSIONS

Operating System: KDE neon 5.21 KDE Plasma Version: 5.21.4 KDE Frameworks Version: 5.81.0 Qt Version: 5.15.2 Kernel Version: 5.4.0-59-generic OS Type: 64-bit Graphics Platform: X11 Processors: 8 × Intel® Core™ i7-4770 CPU @ 3.40GHz Memory: 15,6 GiB of RAM Graphics Processor: GeForce GTX 660 Ti/PCIe/SSE2


Original report filed against KDE: https://bugs.kde.org/show_bug.cgi?id=436390

Abyss777 commented 2 years ago

Can confirm the issue. pkcon update just hung on Running 5% and eat 100% of CPU. I have to Ctrl+C it and rerun with sudo pkcon update

ximion commented 2 years ago

Which version of PackageKit do is installed on your systems?

Abyss777 commented 2 years ago

packagekit/focal-security,focal-updates,now 1.1.13-2ubuntu1.1 amd64

Retested it, now it hangs on Running step, but don't show any percentages.

ximion commented 2 years ago

Hmm, very strange - maybe this is debconf-related... Will this eventually complete? Can you run sudo killall packagekitd ; sudo /usr/libexec/packagekitd --verbose in one terminal, run your update operation in another terminal and check the log in the packagekitd window? (maybe attach it even). Your PackageKit version is fairly old though and there have been quite a lot of changes on the aptcc backend meanwhile, so testing this with a more recent PK version may also be very useful. There's a good chance that this issue is already fixed.

Krzmbrzl commented 2 years ago

I also have version 1.1.13 installed

Can you run sudo killall packagekitd ; sudo /usr/libexec/packagekitd --verbose in one terminal, run your update operation in another terminal and check the lock in the packagekitd window? (maybe attach it even).

For the next update, I'll try to think about doing it this way

Abyss777 commented 2 years ago

Your PackageKit version is fairly old though and there have been quite a lot of changes on the aptcc backend meanwhile, so testing this with a more recent PK version may also be very useful. There's a good chance that this issue is already fixed.

It is KDE Neon distro, that forces using pkcon instead of pure apt (I don't understand why, but does not matter here) It's based on Ubuntu 20.04 LTS. Will be able to test with new packagekit only in April after Ubuntu 22.04 LTS release.

I tested it, but didn't come across with problem this time. packagekitd_verbose.txt

See strange

11:55:16        PackageKit          changing transaction to exclusive mode
11:55:16        PackageKit          transaction now waiting-for-auth
11:55:16        PackageKit          authorizing action org.freedesktop.packagekit.system-update
11:55:19        PackageKit          engine idle zero as 1 transactions in progress
11:55:19        PackageKit          idle is 0
11:55:24        PackageKit          engine idle zero as 1 transactions in progress
11:55:24        PackageKit          idle is 0
11:55:25        PackageKit          transaction now ready
11:55:25        PackageKit          changing transaction to exclusive mode
11:55:25        PackageKit          1 transactions in list, 1 committed but not finished
11:55:25        PackageKit          transaction now running
11:55:25        PackageKit          install uid now 1000
11:55:25        PackageKit          install cmdline now PackageKit: update-packages
11:55:25        PackageKit          setting role for /51_ccceaaaa to update-packages

This was when I entered password in dialog (like kdesudo or similar). Is it normal, that install uid now 1000 same as my, and didn't change after auth?

Will retest it later with bigger list of new packets.

PS for me right command was sudo killall packagekitd ; sudo /usr/lib/packagekit/packagekitd --verbose

IGR2014 commented 2 years ago

Same on KDE Neon 20.04 with pkcon v1.1.13.

Suggestion re-running with sudo helped, thanks!

ageorgal commented 1 year ago

Same on me. It worked with sudo pkcon upate

eltrantaqo commented 8 months ago

I was having the same issue and used Sudo pkcon update and it worked. I'm on version 22.04 btw.

sidt4 commented 7 months ago

I was having the same issue and used Sudo pkcon update and it worked. I'm on version 22.04 btw.

I see the hang in 22,04, but that is caused because GNOME Software was doing a costly get-update-detail transaction, which takes minutes to complete (fixed in recent GNOME Software), and pkcon update command was doing a synchronous update call. Hence it will block until the get-update-detail transaction is completed. sudo shouldn't have made any difference here.

@eltrantaqo Is it possible that sudo just worked because the get-update-detail transaction was completed by then, and plain pkcon update without sudo would have worked too ?

pkmon command can be used to view current active transactions in packagekit

sidt4 commented 7 months ago

Also, pkcon update needs successful authentication to proceed with the update. This is done through Polkit, which should offer a authentication dialog as below. If there is no authentication dialog, it's a bug (unless Polkit is configured to not require authentication) and most likely related to Packagekit <-> Polkit interaction.

Below is the screenshot from Ubuntu 22.04 when running pkcon update as normal user (pkcon: 1.2.5)

pkcon-polkit-auth

armando-ota commented 6 months ago

Mine is stuck at

Getting updates                         [                         ] (0%) 
sidt4 commented 6 months ago

@armando-ota: pkmon command can be used to view current active transactions in packagekit.

What's the output of pkmon command when stuck ?

armando-ota commented 6 months ago

that was it

Zitrax commented 4 months ago

sudo solved it for me as well, sounds like the simplest solution would be to just abort and say "pkcon update needs to run with sudo" when ran from the console

eduarddejong commented 3 months ago

Ok, since I run KDE Neon in a virtual machine and maintain a backup of it, I was able to repeatedly redo things exactly the same way, by restoring the entire thing and it's state. So I could try a couple of things now.

I haven't been touching this virtual machine for a week or 2 and now I just tried to update things using a command.

I am in fact still new to this specific Linux distribution so I don't know everything either, I am actually unsure if sudo is supposed be used for PackageKit or not. To be honest I have never seen any distribution that officially recommends PackageKit as the only way to run updates when doing it using the terminal. But KDE Neon does it that way.

But the other times that I ran pkcon update it just worked, just like pkcon refresh works without it. After confirming with "y", it simply asks you to enter the password in a graphical prompt and then it does the job.

Well, in another KDE Neon VM, running Unstable, I indeed got the same hang problem a lot earlier, which I solved with sudo apt full-upgrade. But that's a testing system for the developers of KDE, which obviously can have bugs.

Now I am experiencing the same hang in a KDE Neon User system, and I did not expect this problem.

One CPU core is stuck 100% when the hang happens (so it quite definitely has to be an infinite loop issue).

I now tried it a couple of times over (restoring the entire VM every time so that I don't have to fix broken stuff after killing the frozen update). Turns out the freeze happens at random moments, sometimes it's during the download, other times it's in the middle of the actual upgrade.

All of the following workarounds appear to work though:

My expectation, when pkcon update already shows a password prompt to obtain elevation, was that I was doing things the right way, especially because it usually works.

Given the fact that a CPU gets stuck at 100%, I assume an actual bug is going on.

sidt4 commented 2 months ago

@eduarddejong Thanks for the analysis.

  1. Which version (pkcon --version) of PackageKit was that on ?
  2. Can you follow the steps in https://github.com/PackageKit/PackageKit/issues/522#issuecomment-1042576586 and attach the output when it hangs ?