Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Linux Apt Commands to Handle Lock Timeouts #1861

Merged
merged 51 commits into from
Jul 10, 2024

Conversation

nagilson
Copy link
Member

@nagilson nagilson commented Jul 3, 2024

resolves #1806 (comment)

A lot of users are seeing failure due to the DPKG lock being held by another process. We can add a flag to wait for the lock to be freed. This wont fix everything, as Apt will return 100 whenever there is any failure. https://github.com/Debian/apt/blob/aa56836331870d975c212a5df2f13db9ce3914bf/apt-private/private-cmndline.cc#L602

This means the errors we are seeing are not just due to locking errors. But, perhaps this will help.

This will also add a timeout to our own executions so that they dont keep the lock.

Also this will try to run update twice, to see if that 2nd try will work. It seems a bit silly, but it does actually seem to improve the chance of success when something else is running on the system.

The timeout time is mildly arbitrary.... we can try to improve that in the future to be based off a fraction of the total timeout time, or something like this. But I would like to see the impact of how much this helps without this change.

nagilson and others added 30 commits June 25, 2024 16:11
This prevents us from having to run commands twice to get the status and stdout.

Caution must be taken to make sure that the assumptions here in what is returned as stdout vs stderr are correct.

Furthermore, when looking at the code, I saw something that looked just plain incorrect, so I will need to investigate that by adding the TODO before merge
This will allow us to not count times when users never respond to the installer as a failure and or remediate when the installer is taking too long.
We also pass the -y flag when it can help push through updates.
Apt will return 100 whenever there is any failure. https://github.com/Debian/apt/blob/aa56836331870d975c212a5df2f13db9ce3914bf/apt-private/private-cmndline.cc#L602

This means the errors we are seeing are not just due to locking errors. But, perhaps this will help.

Also this will try to run update twice, to see if that 2nd try will work. It seems a bit silly, but it does actually seem to improve the chance of success when something else is running on the system.
it doesnt do anything for update lol
@nagilson nagilson requested a review from a team July 10, 2024 00:08
{
await release();
await lockfile.lock(lockPath, { retries: { retries: 10, minTimeout: 5, maxTimeout: 10000 } })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What units are the min and max timeout in?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are in MS. The library will do an exponential equation where it starts trying again after 5 ms and then takes longer each retry until its at 10000 ms.

@nagilson nagilson enabled auto-merge (squash) July 10, 2024 18:15
@nagilson nagilson disabled auto-merge July 10, 2024 18:25
@nagilson nagilson merged commit d602636 into dotnet:main Jul 10, 2024
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apt-Get Lock can be Busy when Executing Linux Install
2 participants