apt-check hangs, preventing login via SSH
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | update-notifier (Ubuntu) |
Medium
|
Unassigned | ||
Bug Description
Binary package hint: update-notifier
While investigating protracted hangs in the remote login process, I noticed that apt-check is called to update the list of available updates and print the number of updatable packages in the MOTD. As it so happens, apt-check often hangs in mid-update, which effectively prevents remote login via SSH from taking place.
Related bugs:
* bug 525674: apt-check hangs, preventing login via SSH
* bug 1527710: apt-get update triggers asynchronous task
* bug 1533243: preseeded installation fails on critical question: partman/
ProblemType: Bug
Architecture: i386
Date: Mon Feb 22 12:20:16 2010
DistroRelease: Ubuntu 10.04
Package: update-
PackageArchitec
ProcEnviron:
LANGUAGE=
PATH=(custom, user)
LANG=fi_FI.UTF-8
SHELL=/bin/bash
ProcVersionSign
SourcePackage: update-notifier
Uname: Linux 2.6.32-14-generic i686
Related branches
- Dennis Kaarsemaker: Pending requested 2014-05-03
- Diff: 0 lines
| Martin-Éric Racine (q-funk) wrote : | #1 |
| Martin-Éric Racine (q-funk) wrote : | #2 |
| Scott Moser (smoser) wrote : | #3 |
I was about to file this bug, so I'll confirm it. I have not seen the apt-check hang entirely, but it is very slow to run, and blocks initial.
Note, you may have seen what appeared to be a hang due to the very bad performance of security.ubuntu.com in the past few days. That performance was due to it being slammed by openoffice.org security update.
This is quite an annoyance on a newly booted ec2 instance.
| Changed in update-notifier (Ubuntu): | |
| importance: | Undecided → Medium |
| status: | New → Confirmed |
| tags: | added: ec2-images uec-images |
| Dan Muresan (danmbox) wrote : | #4 |
What connects loging in to running update-notifier? I'd like to disable that (especially for SSH logins) without removing update-notifier completely.
| Dan Muresan (danmbox) wrote : | #5 |
To answer self, there are pam_motd references in /etc/pam.
And since the very same friendly developers will be in charge of the next release (and the next one after that), there's no telling how many more pleasant surprises like this one we will have the next time we upgrade. Of course they never tell you how to disable these "surprises" in the RELEASE NOTES -- that would spoil the fun. They like you spending time treasure-hunting the goodies they hide in various dark corners of the distro.
| RichardNeill (ubuntu-richardneill) wrote : | #6 |
This is really painful - although I don't experience complete hangs, I do experience 12-second+ delays while
the script "90-updates-
The workaround is: chmod -x /etc/update-
However, it seems to me that this should be a cron-job which runs once an hour (and @reboot). There's no need for it to happen at the precise moment where I log in.
| RichardNeill (ubuntu-richardneill) wrote : | #7 |
(P.S. Even worse is connecting via a stack of SSH tunnels, eg behind a firewall. It takes almost 30 seconds to get a prompt, and ssh -vvv doesn't help identify the issue).
| RichardNeill (ubuntu-richardneill) wrote : | #8 |
Interestingly, 14.04 seems to be much better at this than 12.04, takling around 1.5 sec rather than 12.
However, it's interesting how much faster it can still be without this.
Here is a measurement I made. This is 14.04 server on the LAN, with ssh-key authentication, and I repeated serveral times:
time ssh server_on_lan true
With the /etc/update-
After chmod -x, this takes ~ 0.15 sec.
I hope that helps,
| ChristianEhrhardt (paelzer) wrote : | #9 |
Other MOTD plugins use caching, for example /usr/lib/
if [ -f /var/run/
cat /var/run/
fi
Actually /usr/lib/
It stores its result in:
/var/
This is what the call to "/usr/lib/
But it executes slow commands like find apt-check synchronously.
Yes a cron job might be nice, but it is rather "invasive" in changing the general behaviour maybe more than required.
Why not just executing the "slow parts" like find and apt-check asynchronously.
One can still evolve that approach later on an move (instead or additionally) the async part into a cron job if required.
It comes at "the risk" of having one outdated info on login.
But since updates don't change every second anyway it is probably better than waiting on each login.
Especially with all the examples made like scp tabbing, slow network and so on.
The atomicity issue with updating the temporary file already exists in todays code with regards to concurrent logins. But we can improve that as well by using a temporary file and mv.
The following are suggestions to fix it in trusty, vivid, wily and upstream.
| ChristianEhrhardt (paelzer) wrote : | #10 |
| ChristianEhrhardt (paelzer) wrote : | #11 |
The attachment "Fix for trusty" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.
[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]
| tags: | added: patch |
| ChristianEhrhardt (paelzer) wrote : | #15 |
FYI - After a discussion I'll likely revamp the patches for wily and upstream the next days.
Until then we will also decide if this is worth SRUs for trusty/vivid.
| ChristianEhrhardt (paelzer) wrote : | #16 |
Here the bigger, but more architecturally complete solution for wily&upstream (which is actually identical at this time).
Summary:
- move the actual updating part out of the pam based trigger completely (avoids slowdown)
- pam based motd now only prints the cached info (if existing)
- hook into apt with APT::Update:
- removed one level of indirection (apt hook -> stamp file -> on pam login check stamp -> update) to the more separate
(apt hook -> update cached info) (on pam login -> print cached info)
- while the chance of a concurrent update is now (almost) impossible it keeps the atomic cache update and cleanup to be sure
It was working find in all my builds and tests on wily.
Attaching for review ...
| Martin Pitt (pitti) wrote : | #18 |
Thanks Christian! Some remarks:
- The introduction of data/get-
cat /var/lib/
or
[ ! -r /var/lib/
if you prefer that. This would be simpler IMHO.
- changelog should point out that data/update-
These are just nitpicks, this looks fine by and large. Thanks for working on this!
| Michael Vogt (mvo) wrote : | #19 |
Thanks for working on this! Diff looks good (pitti pointed some minor things out already).
One more thing, please keep the part:
"DPkg:
the part of update-notifier that displays a icon (used in xfce iirc) will depend on this file, it uses inotify to know reliable when apt was finished.
| Scott Moser (smoser) wrote : | #20 |
hey. saw this in my inbox, and very happy! thank you for working on this.
one note, in update-
+ trap cleanup EXIT
+ tmpfile=$(mktemp)
if tmpfile was set in the environment prior to this program running, and you exited for some reason between those two, then you'd rm the previously set 'tmpfile'.
the easy fix is to just declare 'tmpfile=' before trapping cleanup.
| ChristianEhrhardt (paelzer) wrote : | #21 |
Martin:
- I already removed one indirection with my former patch and love to remove one more.
Simple code = good code - thanks for the good hint.
- I changed it slightly to use the existing variable so people recognize from which code
it came and to avoid issues if one ever changes only one occurrence of that file name.
- changelog now contains the original intention (no stall to logins) and the avoidance of
stalling apt-get update along with all other minor fixes that came up along the way
Michael:
- Good catch, I didn't realize that this were two totally independent pieces.
Scott:
- Another good catch, of a potentially rare but nasty to track down issue
Overall I want to thank all reviewers a lot - I highly appreciate this real community feeling.
The patch got way better and smaller at once.
Thank You!
| ChristianEhrhardt (paelzer) wrote : | #22 |
| Scott Moser (smoser) wrote : | #23 |
looks good to me.
| Martin Pitt (pitti) wrote : | #24 |
Thank you! Uploaded.
| Changed in update-notifier (Ubuntu): | |
| status: | Confirmed → Fix Committed |
| Launchpad Janitor (janitor) wrote : | #25 |
This bug was fixed in the package update-notifier - 3.164
---------------
update-notifier (3.164) xenial; urgency=medium
* debian/
- Now directly prints the cached info if available
=> avoid login stalls due to motd updates (LP: #525674)
- Also fixes a former potential issue of existing but not readable cached
info by changing the test from -e to -r
* debian/
- Now additionally triggers the an asynchronous background update of the
cached info via update-
APT:
* data/update-
- This now only contains the slow part of actually 'updating the cached
info'.
- It executes asynchronously to avoid stalling apt-get update.
- The file is no more called by pam to avoid login stalls.
- It also fixes an issue with concurrent updates clobbering the
cached file via mv being atomic
-- Christian Ehrhardt <email address hidden> Fri, 13 Nov 2015 12:28:25 +0100
| Changed in update-notifier (Ubuntu): | |
| status: | Fix Committed → Fix Released |
| description: | updated |
| description: | updated |


Subscribed Ubuntu Server Team as this is an issue that prevents remote servicing of Lucid hosts.