WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSLg generates a large number of RdClientAutoTrace files

Open GZTimeWalker opened this issue 2 years ago • 34 comments

Windows Version

10.0.x

WSL Version

0.58.3.0 - now

Are you using WSL 1 or WSL 2?

  • [X] WSL 2

Repro Steps

The details can be found at the discussion https://github.com/microsoft/WSL/discussions/8486

we think this should be an issue.

Expected Behavior

do nothing

Actual Behavior

wsl generates a lot of RdClientAutoTrace files that take up so much disk space.

GZTimeWalker avatar Jun 18 '23 16:06 GZTimeWalker

Some potentially relevant elements:

https://github.com/microsoft/WSL/issues/8544#issuecomment-1197586956 https://github.com/microsoft/WSL/issues/9752#issuecomment-1478381675

GZTimeWalker avatar Jun 18 '23 16:06 GZTimeWalker

It's devastating my poor 512GB SSD is full just three days after I removed the files. Is there any temporary solution for this?

ariaieboy avatar Jun 19 '23 00:06 ariaieboy

It's devastating my poor 512GB SSD is full just three days after I removed the files. Is there any temporary solution for this?

my current solution is to have a scheduled task that deletes those files periodically. I am doing it for wsl as well as for some outlook trace files that also have the same behaviour. Script here: https://github.com/0x6f677548/shell-utils/blob/main/file/Delete-OldFiles.ps1

0x6f677548 avatar Jun 19 '23 11:06 0x6f677548

Temporary solution, turn off support for GUI applications in WSL:

User can also choose to turn off the system distro entirely by adding the following entry in their .wslconfig file (located at c:\users\MyUser\.wslconfig). This will turn off support for GUI applications in WSL.

[wsl2]
guiApplications=false

https://github.com/microsoft/wslg#wslg-system-distro https://github.com/microsoft/WSL/discussions/8486#discussioncomment-5560022

haomingz avatar Jun 21 '23 06:06 haomingz

Temporary solution, turn off support for GUI applications in WSL:

User can also choose to turn off the system distro entirely by adding the following entry in their .wslconfig file (located at c:\users\MyUser.wslconfig). This will turn off support for GUI applications in WSL.

[wsl2]
guiApplications=false

https://github.com/microsoft/wslg#wslg-system-distro #8486 (comment)

I've added this to my .wslconfig but it didn't help

ariaieboy avatar Jun 21 '23 11:06 ariaieboy

Same issue here, seems like compiled version of RD Client has a bug:

MSRDC_WILFailure : "D:\a\_work\1\s\RdClient\RdClient.SessionHost\exe\msrdc\MSRDCRecoveryManager.cpp",      175, "", "msrdc.exe",    14448,        1,        0, 0x80070002, true
MSRDC_WILFailure : "D:\a\_work\1\s\RdClient\RdClient.SessionHost\exe\msrdc\MSRDCRecoveryManager.cpp",       42, "", "msrdc.exe",    14448,        1,        0, 0x80070002, true
MSRDC_WILFailure : "D:\a\_work\1\s\RdClient\RdClient.SessionHost\exe\msrdc\MSRDCRecoveryManager.cpp",       31, "", "msrdc.exe",    14448,        1,        0, 0x80070002, true

Update: Upon looking into the trace log I found that "EnableMSRDCTelemetry" is missing within registry. I may have fixed the issue by installing Microsoft Remote Desktop MSI (not sure if that works with the AppStore version) followed by system reboot. The error logs for now stopped spamming the RdClientAutoTrace directory.

You can get it here: https://go.microsoft.com/fwlink/?linkid=2068602

pasujemito avatar Jun 26 '23 11:06 pasujemito

I discovered I had this issue last night, my 500GB SSD was filled in less than an hour when I walked away from my PC. I tried updating the RD Client as https://github.com/microsoft/WSL/issues/10216#issuecomment-1607242027 mentioned above and that did not fix it for me.

What did fix it for me was adding the following line to .wslconfig as https://github.com/microsoft/WSL/issues/10216#issuecomment-1600239227 mentions.

[wsl2]
guiApplications=false

My WSL version output if it's helpful:

WSL version: 1.3.11.0
Kernel version: 5.15.90.2-3
WSLg version: 1.0.54
MSRDC version: 1.2.4240
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25880.1000-230602-1350.main
Windows version: 10.0.22621.1992

Last time I know it was working was about a week ago if that's helpful.

BorkforceOne avatar Jul 16 '23 15:07 BorkforceOne

I came up with a simple solution that doesn't require disabling guiApplications:

  1. Delete the folder %temp%\DiagOutputDir\RdClientAutoTrace
  2. Create a txt file under %temp%\DiagOutputDir and rename it to RdClientAutoTrace, make sure you have delete the extension name .txt of the file
  3. No RdClientAutoTrace files will be created any more

hez2010 avatar Jul 21 '23 17:07 hez2010

I just had to delete over 100gb of these files.

This needs to be fixed asap.

tig avatar Jul 24 '23 02:07 tig

Does this method have a side effect ?

No side effects. Those files are all tracing logs.

hez2010 avatar Jul 24 '23 05:07 hez2010

I have the same issue, my disk consumed almost all of the usable space overnight.

influctuation avatar Jul 28 '23 23:07 influctuation

I deleted following option out of my .wslgconfig (%UserProfile%.wslgconfig) WSL2_WESTON_SHELL_OVERRIDE=desktop-shell

Now it runs perfect.

018054646 avatar Aug 09 '23 12:08 018054646

I came up with a simple solution that doesn't require disabling guiApplications:

1. Delete the folder `%temp%\DiagOutputDir\RdClientAutoTrace`

2. Create a txt file under `%temp%\DiagOutputDir` and rename it to `RdClientAutoTrace`, make sure you have delete the extension name `.txt` of the file

3. No RdClientAutoTrace files will be created any more

Is it ok to do this? im just asking will it corrupt my wsl?

matheeshapathirana avatar Aug 13 '23 05:08 matheeshapathirana

Is it ok to do this? im just asking will it corrupt my wsl?

It won't. I have used this trick for several weeks and didn't encounter any issue.

hez2010 avatar Aug 13 '23 10:08 hez2010

Is it ok to do this? im just asking will it corrupt my wsl?

It won't. I have used this trick for several weeks and didn't encounter any issue.

Ok thanks.

matheeshapathirana avatar Aug 13 '23 12:08 matheeshapathirana

I deleted following option out of my .wslgconfig (%UserProfile%.wslgconfig) WSL2_WESTON_SHELL_OVERRIDE=desktop-shell

Now it runs perfect.

I'm wondering what leads this to fix it for you... 🤔

thopiddock avatar Aug 17 '23 09:08 thopiddock

Is it ok to do this? im just asking will it corrupt my wsl?

It won't. I have used this trick for several weeks and didn't encounter any issue.

I tested it. Seems to not have any issues up to now.

farzadso avatar Aug 24 '23 08:08 farzadso

Just noticed my system drive was full. Came across this post and deleted 384GB of ETL files!

frasermclean avatar Aug 27 '23 01:08 frasermclean

I deny all permissions of SYSTEM user group, seems it's still adding files but just few files image

oclockvn avatar Sep 04 '23 03:09 oclockvn

That problem fill my disk. and cursor loading blinking.

Fixing temporary:

cmd>wsl --shutdown cmd>rmdir /s /q "%temp%\DiagOutputDir\RdClientAutoTrace" cmd>notepad %UserProfile%/.wslconfig

WSL2_WESTON_SHELL_OVERRIDE=desktop-shell
guiApplications=false

kyesil avatar Oct 12 '23 07:10 kyesil

Hopefully the below can be used in the interim..

Stop-WSLAndCleanRdClientAutoTrace -RepoOwner 'microsoft' -RepoName 'WSL' -IssueNumber 10216
function Stop-WSLAndCleanRdClientAutoTrace {
<#
.SYNOPSIS
Stops all WSL processes and cleans up the RdClientAutoTrace directory if a specific GitHub issue is still open.

.DESCRIPTION
This function checks the status of a specified GitHub issue. If the issue is open, it proceeds to shut down all WSL instances, stop the LxssManager service, delete the RdClientAutoTrace directory, and create a dummy file to prevent future logging. Requires administrative privileges to run.

.PARAMETER RepoOwner
The owner of the GitHub repository.

.PARAMETER RepoName
The name of the GitHub repository.

.PARAMETER IssueNumber
The number of the GitHub issue to check.

.EXAMPLE
Stop-WSLAndCleanRdClientAutoTrace -RepoOwner 'microsoft' -RepoName 'WSL' -IssueNumber 10216

Checks the status of GitHub issue #10216. If open, applies the workaround to stop WSL processes and clean the RdClientAutoTrace directory.
#>
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$RepoOwner,

        [Parameter(Mandatory = $true)]
        [string]$RepoName,

        [Parameter(Mandatory = $true)]
        [int]$IssueNumber
    )

    # Function to check the status of a GitHub issue
    function Check-GitHubIssueFixed {
        param (
            [string]$RepoOwner,
            [string]$RepoName,
            [int]$IssueNumber
        )

        $issueApiUrl = "https://api.github.com/repos/$RepoOwner/$RepoName/issues/$IssueNumber"

        try {
            $issue = Invoke-RestMethod -Uri $issueApiUrl -Headers @{Accept = 'application/vnd.github.v3+json'}
            return $issue.state -eq 'closed'
        }
        catch {
            Write-Warning "Failed to check GitHub issue status. Error: $_"
            return $false
        }
    }

    # Ensure the function is running with administrative privileges
    if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
        Write-Error "This function requires administrative privileges. Please run PowerShell as an administrator."
        return
    }

    # Check if the GitHub issue is fixed
    $issueFixed = Check-GitHubIssueFixed -RepoOwner $RepoOwner -RepoName $RepoName -IssueNumber $IssueNumber

    if (-not $issueFixed) {
        Write-Host "The GitHub issue is still open. Applying the workaround..."

        # Shutdown all instances of WSL
        wsl --shutdown

        # Stop the LxssManager service
        Get-Service LxssManager | Stop-Service -Force -ErrorAction Stop

        # Define the target directory and file paths
        $tempPath = [System.Environment]::ExpandEnvironmentVariables('%temp%\DiagOutputDir')
        $targetDir = Join-Path -Path $tempPath -ChildPath "RdClientAutoTrace"
        $dummyFile = Join-Path -Path $tempPath -ChildPath "RdClientAutoTrace.txt"

        # Delete the RdClientAutoTrace directory if it exists
        if (Test-Path -Path $targetDir) {
            Remove-Item -Path $targetDir -Recurse -Force -ErrorAction Stop
        }

        # Ensure the DiagOutputDir directory exists
        if (-not (Test-Path -Path $tempPath)) {
            New-Item -ItemType Directory -Path $tempPath | Out-Null
        }

        # Create a dummy RdClientAutoTrace file
        New-Item -ItemType File -Path $dummyFile | Out-Null

        # Rename the dummy file to RdClientAutoTrace (without .txt extension)
        Rename-Item -Path $dummyFile -NewName ($dummyFile -replace '\.txt$','') -ErrorAction Stop

        Write-Host "WSL processes stopped and RdClientAutoTrace directory handled."
    }
    else {
        Write-Host "The GitHub issue has been resolved. No need to apply the workaround."
    }
}

Donovoi avatar Mar 02 '24 23:03 Donovoi

Just deleted ~100 gigs of this garbage from the last week and applied the workaround. This needs to be fixed.

Genda1ph avatar May 12 '24 21:05 Genda1ph

I came up with a simple solution that doesn't require disabling guiApplications:

  1. Delete the folder %temp%\DiagOutputDir\RdClientAutoTrace
  2. Create a txt file under %temp%\DiagOutputDir and rename it to RdClientAutoTrace, make sure you have delete the extension name .txt of the file
  3. No RdClientAutoTrace files will be created any more

Didn't work. After I deleted, it creates a new Rd folder and keeps generating the file, do I miss anything? image

kansu4 avatar Aug 02 '24 03:08 kansu4

do I miss anything? Apparently the extension name is hidden on your system and you didn't remove the extension name from the file you created.

hez2010 avatar Aug 02 '24 06:08 hez2010

Bump.

When this is triggered, it wears down SSDs, causes system drive to fill up and WSL to stutter like mad. This is a major regression and it looks like wasn't so much as acknowledged by m$.

Genda1ph avatar Oct 17 '24 23:10 Genda1ph

the error that causes the trace file to be created also un-focused me, which is an inconvenience for some fullscreen games that minimize when unfocused; a solution i found was to run a GUI app in the background with explorer closed (maybe not needed?), this no longer caused the random un-focusings and creation of log files

yoinked-h avatar Oct 26 '24 17:10 yoinked-h

Didn't work

You didn't delete .txt file extention, therefore it shown in Explorer with type Text Document.

likemusic avatar Nov 02 '24 19:11 likemusic

This issue is opened for 2 years now. I've just removed 100 GB of trash generated since.. 27.12! Only 6 days! This is unacceptable!

Acrivec avatar Jan 02 '25 15:01 Acrivec

Next to the .wslconfig configuration file (usually in the C:\Users[User] folder), create a new .wslgconfig file. Name differs by one letter. In it add two lines:

[system-distro-env]
WSLG_USE_MSTSC=true

Restart WSL: wsl --shutdown No more RdClientAutoTrace directory will be created.

You can check it by changing the value. If true - RdClientAutoTrace folder and a bunch of files are not created. If false or absence of parameter or configuration file - it is created.

Application of systemDistro is not necessary now. Actually, it could have been suggested before. I had to dig into the wslg code.

glogrus avatar Feb 20 '25 15:02 glogrus

[system-distro-env]
WSLG_USE_MSTSC=true

Causes problems for me when I start an Ubuntu terminal session. Pops up a Remote Desktop help box or something.

denyeo avatar Mar 01 '25 15:03 denyeo