Skip to content

MongoDB 9.0 fails with Windows bind mounts in WSLC but works in Docker Desktop #42129

Closed
microsoft/openvmm
#4861

Description

@afscrome

Windows Version

10.0.26300.9818

WSL Version

3.0.4.0 (WSLC also reports 3.0.4.0)

Are you using WSL 1 or WSL 2?

WSL 2

Kernel Version

6.18.54.1-microsoft-standard-WSL2

Distro Version

Ubuntu-26.04 for the native WSL comparison; the failing reproduction runs in WSLC.

Other Software

  • Image: mongo:9.0
  • MongoDB version observed in WSLC reproduction: 9.0.4
  • Docker Desktop succeeds in the comparison below; its version and backend were not captured.

Repro Steps

MongoDB fails during initialization when /data/db is bind-mounted to a Windows directory using WSLC. The equivalent Docker Desktop command succeeds using the same Windows directory and image tag.

Run in PowerShell:

$dir = [System.IO.Directory]::CreateTempSubdirectory('mongodb-repro-').FullName

# Fails
wslc run --rm --mount "type=bind,src=$dir,target=/data/db" mongo:9.0

# Works
 docker run --rm --mount "type=bind,src=$dir,target=/data/db" mongo:9.0

The Docker command runs until stopped manually. The failure reproduces without Aspire, authentication, TLS, published ports, custom MongoDB arguments, or entrypoint overrides.

Both commands select mongo:9.0; the exact image digests across the two runtimes were not compared.

Expected Behavior

MongoDB initializes successfully with the Windows-directory bind mount, as it does under Docker Desktop.

Actual Behavior

WSLC's MongoDB container fails during WiredTiger initialization:

/data/db/: directory-sync: fdatasync
Invalid argument (22)
WT_PANIC: WiredTiger library panic (-31804)

WSLC exits with code 139.

Additional isolation

A syscall probe shows that directory fdatasync() fails specifically on the WSLC Windows bind mount:

Environment/storage Directory fsync() Directory fdatasync() MongoDB
WSLC Windows bind mount, virtiofs Succeeds EINVAL Fails
WSLC Linux-backed named volume, ext4 Succeeds Succeeds Works
Native WSL2 Windows directory, 9p/DrvFs Succeeds Succeeds Works
Docker Desktop Windows bind mount Not independently probed Not independently probed Works

Regular-file fdatasync() succeeds on the WSLC bind mount; the observed failure concerns directory handles.

The WSLC bind mount appears in /proc/mounts as:

drvfs /probe virtiofs rw,relatime 0 0

A minimal directory syscall probe, run with Python inside the environment being tested, is:

import os

fd = os.open('/probe', os.O_RDONLY)
try:
    os.fdatasync(fd)
finally:
    os.close(fd)

Here /probe is the Windows-directory bind-mount destination. In WSLC it raises OSError: [Errno 22] Invalid argument; os.fsync(fd) succeeds on the same directory. Both calls succeed on an ext4 named volume and on the ordinary WSL2 9p Windows-drive mount.

The same MongoDB 9.0.4 executable also starts successfully when run natively in Ubuntu-26.04 with data under /mnt/c/temp, where the Windows drive uses 9p/DrvFs. Initial startup and a second startup against the same database directory both answer a MongoDB hello command successfully and shut down with exit code 0. This uses the same WSL kernel as the WSLC reproduction.

Related reports

These are historical precedents, not confirmed duplicates. Current Docker Desktop succeeds in the comparison above.

Workaround

Use a Linux-backed named volume for MongoDB data in WSLC instead of a Windows-directory bind mount.

Diagnostic Logs

The standalone WSLC reproduction emitted:

2026-11-01T20:19:14.090+00:00
WiredTiger error message
error: 22
msg: int __posix_sync(WT_SESSION_IMPL *, int, const char *, const char *):203:/data/db/: directory-sync: fdatasync
error_str: Invalid argument
error_code: 22

WiredTiger error message
error: -31804
msg: int __posix_sync(WT_SESSION_IMPL *, int, const char *, const char *):203:the process must exit and restart
error_str: WT_PANIC: WiredTiger library panic
error_code: -31804

WSL diagnostic tracing has not yet been collected.

Activity

  1. github-actions commented on Nov 1, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. github-actions commented on Nov 1, 2026

    @github-actions
    Contributor
    Diagnostic information
    .wslconfig found
    	Custom kernel command line found: 'cgroup_no_v1=all systemd.unified_cgroup_hierarchy=1'
    Detected appx version: 3.0.4.0
    
  3. shuaiyuanxx commented on Nov 2, 2026

    @shuaiyuanxx
    Contributor

    Thanks for the information. The trace confirms that WSLC’s virtiofs backend returns EINVAL for directory fdatasync() requests, while directory fsync() and regular-file fdatasync() succeed.

    Source inspection and local reproduction point to the directory-sync handler reusing the regular-file data-only flush path (NtFlushBuffersFileEx with FLUSH_FLAGS_FILE_DATA_ONLY). That call fails for directory handles on the tested NTFS system; the error is translated to EINVAL, triggering WiredTiger’s panic.

    The proposed fix is to use a full flush for directory sync requests, leaving regular-file behavior unchanged.

     fn fsync_dir(&self, request: &Request, fh: u64, flags: u32) -> lx::Result<()> {
    //  self.fsync(request, fh, flags)
        self.fsync(request, fh, flags & !FUSE_FSYNC_FDATASYNC)
     }
  4. ggarzia-MSFT commented on Nov 4, 2026

    @ggarzia-MSFT
    Contributor

    reopening because this is fixed in openvmm but wsl still uses an older build so the bug is still present

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions