#1542·litestream

FsyncDir fails with "Access is denied" on Windows, so replication stops (v0.5.16+)

Author: ZacKienzle2Created Sep 28, 2026Updated Sep 28, 2026

Bug Description

On Windows, every sync fails with Access is denied from v0.5.16 on, so replication never gets past the first few LTX files.

Since #1344 (commit eeba874a, "fix(replica): fsync directory after durable renames"), internal.FsyncDir opens the directory with os.Open and calls Sync on it:

os.Open gives a read-only handle. On Windows, Sync calls FlushFileBuffers, and Microsoft's documentation says its handle "must have the GENERIC_WRITE access right" (FlushFileBuffers). internal/internal_windows.go has no variant of FsyncDir. The call fails every time.

Environment

Litestream version:

0.5.17

Operating system & version:

Windows 11 Pro 10.0.26200

Installation method:

Binary release, through mise (aqua:benbjohnson/litestream)

Storage backend:

File

Steps to Reproduce

  1. On Windows, take a SQLite database in WAL mode that another process writes a few times a second.
  2. Run litestream replicate -config litestream.yml with the configuration below.
  3. Watch the log.

Expected behavior: L0 LTX files keep arriving in the replica, and the application's checkpoints proceed.

Actual behavior:

  • Seven seconds after start, the store's sync logs sync ltx dir: sync <db dir>\.<db>-litestream\ltx\0: Access is denied. The replica monitor, compaction to level 1 and compaction to level 9 log the same error, and the backoff grows on each retry.
  • The replica received seven L0 files in the first 90 seconds, then nothing more, and a 0-byte ltx\1\...ltx.tmp was left behind.
  • While the syncs failed, the database file wasn't written for several minutes and the application's WAL grew from 4.1 to 7.4 MB.
  • With v0.5.15, which has no FsyncDir, the same configuration replicates, and litestream restore gives a copy that passes PRAGMA integrity_check.

Configuration

litestream.yml
yaml
dbs:
  - path: C:\Users\<user>\<dir>\recorder.sqlite3
    replica:
      path: C:\Users\<user>\<replica dir>

Every other key is at its default.

Logs

Log output
level=INFO msg=litestream version=0.5.17
level=INFO msg="replicating to" type=file sync-interval=1s path="C:\\Users\\<user>\\<replica dir>"
level=ERROR msg="sync error" system=store db=recorder.sqlite3 error="sync: sync ltx dir: sync C:\\Users\\<user>\\<dir>\\.recorder.sqlite3-litestream\\ltx\\0: Access is denied." consecutive_errors=1 backoff=1s
level=ERROR msg="monitor error" system=store db=recorder.sqlite3 replica=file error="write ltx file: sync C:\\Users\\<user>\\<replica dir>\\ltx\\0: Access is denied." consecutive_errors=1 backoff=1s
level=ERROR msg="compaction failed" system=store db=recorder.sqlite3 level=9 error="sync C:\\Users\\<user>\\<replica dir>\\ltx\\9: Access is denied."
level=ERROR msg="compaction failed" system=store db=recorder.sqlite3 level=1 error="write ltx file: sync C:\\Users\\<user>\\<replica dir>\\ltx\\1: Access is denied."
level=ERROR msg="sync error" system=store db=recorder.sqlite3 error="sync: sync ltx dir: sync C:\\Users\\<user>\\<dir>\\.recorder.sqlite3-litestream\\ltx\\0: Access is denied." consecutive_errors=6 backoff=32s

Additional Context

Related: #1342 and #1344, which added the directory sync. A search of the issues for Windows and "Access is denied" didn't find a report of this.