WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Docker Desktop's "resource saver mode" causes WSL to "lock" when AutoMemoryReclaim is set to gradual

Open jtabox opened this issue 1 year ago • 21 comments

Windows Version

Microsoft Windows [Version 10.0.22621.3007]

WSL Version

2.0.14.0

Are you using WSL 1 or WSL 2?

  • [X] WSL 2
  • [ ] WSL 1

Kernel Version

5.15.133.1-1

Distro Version

Ubuntu 22.04

Other Software

Docker Desktop 4.26.1 (131620) - Windows version

Repro Steps

When Docker Desktop is running but is in "Resource Saver" mode, running any command that has to read from the disk will "hang" until I manually "wake up" Docker from its Resource Saver mode (by running a container for example).

I'm not really sure about the "read from disk" part, but it's been the common denominator of commands affected by this (e.g. apt, ls, lsof are all affected, while zsh scripts that are already running or top/htop aren't).

This issue happens when Docker Desktop is running in resource saver mode AND WSL's autoMemoryReclaim is set to gradual.

I've tried the following scenarios and they don't seem to cause the issue:

  • autoMemoryReclaim is set to dropcache
  • autoMemoryReclaim is disabled (commented out in .wslconfig)
  • Docker Desktop is running in its normal mode
  • Docker Desktop isn't running at all

For now I have autoMemoryReclaim set to dropcache, but if you want me to run additional tests or need some other info let me know.

Expected Behavior

Expected the normal command behavior.

Actual Behavior

I've taken a screen recording while the issue happens:

https://github.com/microsoft/WSL/assets/56894914/64ac6b36-90a3-44af-89d5-83fe4e5d864e

Diagnostic Logs

Those are the corresponding WSL logs for the screen recording:

WslLogs-AutoMemReclaim-Gradual-2024-01-23_20-40-10.zip

jtabox avatar Jan 23 '24 21:01 jtabox

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Jan 23 '24 21:01 github-actions[bot]

I also see this with Ansible commands, even ansible --version. If I restart docker or just run any docker command that contacts the daemon, the hanging commands immediately resume.

briantist avatar Apr 01 '24 17:04 briantist

I am also seeing this. I got the hunch that anything accessing the network also hangs, not just what's accessing the file system.

kmoschcau avatar Apr 15 '24 08:04 kmoschcau

I am facing the same issue. Maybe related to #10378

Max-Sum avatar Jun 04 '24 06:06 Max-Sum

same issue here.

it's actually just slowing down the system a lot but not hanging indefinitely.

one can see this if you ran "service --status-all". it takes minutes to list services one by one. if i stop docker desktop, then the command finishes quickly.

cwjacklin avatar Aug 15 '24 09:08 cwjacklin

My problem is similar but not identical. I am running WSL2 Ubuntu 22.04. I can run ls and even apt list without problem. They complete instantly. However, running sudo apt-get update hangs indefinitely when Docker Desktop is in "Resource Saver mode".

To fix it, all I have to do is click on the Resume button in Docker Desktop. Then sudo apt-get update runs instantly

image

Note that I also confirmed that I do have autoMemoryReclaim=gradual set in ~/.wslconfig

> wsl -v
WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.4037

I also just updated Docker Desktop today, and the problem persists with Docker Desktop 4.33.1 (161083)

$ docker --version
Docker version 27.1.1, build 6312585

jdblischak avatar Aug 15 '24 18:08 jdblischak

Possibly the root cause is related to systemd and/or cgroupsv2. I ran into this when I set autoMemoryReclaim = gradual to solve a systemd 256 issue (#11857). That issue has two possible workaround. Either set autoMemoryReclaim = gradual, or add in .wslconfig:

[wsl2]
kernelCommandLine = cgroup_no_v1=all systemd.unified_cgroup_hierarchy=1

With autoMemoryReclaim disabled, but kernelCommandLine added to force cgroupsv2, WSL would also freeze for me when Docker Desktop entered Resource Saver mode.

SunMar avatar Jan 30 '25 15:01 SunMar

Possibly the root cause is related to systemd and/or cgroupsv2. I ran into this when I set autoMemoryReclaim = gradual to solve a systemd 256 issue (#11857). That issue has two possible workaround. Either set autoMemoryReclaim = gradual, or add in .wslconfig:

[wsl2]
kernelCommandLine = cgroup_no_v1=all systemd.unified_cgroup_hierarchy=1

With autoMemoryReclaim disabled, but kernelCommandLine added to force cgroupsv2, WSL would also freeze for me when Docker Desktop entered Resource Saver mode.

I confirm that removing the kernelCommandLine fixes this for me. I don't have autoMemoryReclaim set so not sure about that.

To easier reproduce, enable this option, and pause docker engine in WIndows. Then the WSL would freeze.

Image

ly4096x avatar Feb 23 '25 02:02 ly4096x

... Incomprehensible Linux stuff snipped ...

[wsl2]
kernelCommandLine = cgroup_no_v1=all systemd.unified_cgroup_hierarchy=1

I confirm that removing the kernelCommandLine fixes this for me. I don't have autoMemoryReclaim set so not sure about that. ...

Do you mind explaining shortly what that kernel command line does? As in, what does it activate/deactivate/change?

Also, it doesn't exist by default in .wslconfig, so I assume the recommendation is to add it so it does its thing, right?

jtabox avatar Feb 23 '25 14:02 jtabox

In WSL 2.5.1 they removed cgroupv1 support. I removed my .wslconfig and upgraded to this version and Docker Desktop still freezes WSL when it's paused. So as of this version it'll cause your WSL to freeze even if you did not make any changes to .wslconfig.

SunMar avatar Mar 14 '25 09:03 SunMar

I have the same issue, it would cause other distro's wsl ssh port-forwarding to freeze

ICHx avatar May 06 '25 19:05 ICHx

I am seeing the same issue in WSL 2.5.7.0 with the default settings (.wslconfig is empty). Apparently DropCache is the default value, and I am still seeing WSL hang. If I manually instruct Docker to wake up the engine, WSL comes back to life.

cowwoc avatar May 28 '25 18:05 cowwoc

Same issue here. Started experiencing it as of the last month. Upgrading Docker Desktop doesn't fix it either, only clicking resume in the Docker Engine as others have mentioned

BoscoDomingo avatar May 30 '25 10:05 BoscoDomingo

Experiencing the same issue on WSL version: 2.5.7.0 with minimal .wslconfig. WSL completely hangs when Docker enters resource saving mode. Started experiencing it within the last two weeks.

codelotusr avatar Jun 01 '25 11:06 codelotusr

The same hanging symptoms with Docker Desktop for Windows v4.41.2, WSL version: 2.5.8.0 (Kernel version: 6.6.87.1-1) and autoMemoryReclaim is set to dropcache.

amivanoff avatar Jun 05 '25 12:06 amivanoff

Of note, reproduction of this issue is even simpler than adjusting settings. Regardless of autoMemoryReclaim, simply:

  1. Run WSL (wsl on command line)
  2. Run Docker Desktop
  3. Hit the "Pause" button on the "Engine running" section in Docker Desktop (imaged above, resource saver can cause this).
  4. WSL will be frozen at any point this pause is active, and resumes once unpaused.

Perhaps I lack some background information, but I don't feel that docker's engine being paused should make my personal WSL2 distro completely unresponsive.

Versions:

Ubuntu: 24.04.1 LTS
Docker Desktop version: 4.41.2
WSL version: 2.5.7.0
Kernel version: 6.6.87.1-1
WSLg version: 1.0.66
MSRDC version: 1.2.6074
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22621.5335

With this in mind (in addition to several other "workarounds" like attempting to disable Windows 11's efficiency mode), my current approach is to disable "Resource Saver" in the docker settings:

Image

I am now experiencing much less frequent freezing (None so far, as of writing...).

1Rogue avatar Jun 06 '25 14:06 1Rogue

I'm currently experiencing this issue myself. I was able to reproduce it with @1Rogue's steps and his workaround seems to be holding up.

This has to be related to a recent update—either Windows, Docker Desktop, or WSL (wsl --update)—since I've been using Docker Desktop and Ubuntu for over 2 years and never had this problem before.

Started seeing this behavior about a week, maybe two weeks ago.

Recent Updates

Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object HotFixID, Description, InstalledOn
HotFixID Description InstalledOn
KB5059502 Update 5/29/2025 12:00:00 AM
KB5058499 Update 5/29/2025 12:00:00 AM
KB5056579 Update 4/29/2025 12:00:00 AM

System Information

  • NO custom .wslconfig file
  • Ubuntu: 24.04.2 LTS
  • Docker Desktop version: 4.42.0
  • WSL version: 2.5.7.0
  • Kernel version: 6.6.87.1-1
  • WSLg version: 1.0.66
  • MSRDC version: 1.2.6074
  • Direct3D version: 1.611.1-81528511
  • DXCore version: 10.0.26100.1-240331-1435.ge-release
  • Windows version: 10.0.26100.4202

jaas666 avatar Jun 09 '25 22:06 jaas666

There's a dev build with a possible fix here: https://github.com/docker/for-win/issues/14656#issuecomment-2956142140

amweiss avatar Jun 10 '25 14:06 amweiss

That 4.43.0 dev version fixed it for me.

jaas666 avatar Jun 10 '25 16:06 jaas666

Happens to me for the last two days, most likely since KB5058411 and KB5054979 have been installed. Disabling Docker Resource Saver fixes it immediately (meaning stalled processes and windows are revived instantly , without restarting WSL)

pduchesne avatar Jun 12 '25 12:06 pduchesne

It's related to docker desktop.

https://github.com/docker/for-win/issues/14656#issuecomment-2966487210

jaas666 avatar Jun 12 '25 13:06 jaas666