Skip to content

ignore.Matcher goroutine leaks on every folder restart/removal when CacheIgnoredFiles is enabled #10812

Closed

Description

@Soundcreates

What happened?

What happened

ignore.New(fs, ignore.WithCache(true)) starts a background goroutine
(go m.clean(2*time.Hour)) to periodically clean the match cache. The
Matcher also exposes a Stop() method meant to shut that goroutine down.

However, Stop() is never called anywhere in the codebase. Every time a
folder is restarted (e.g. via a config change) or removed, lib/model
builds a brand new ignore.Matcher and drops the reference to the old one
in cleanupFolderLocked — without stopping it first.

What did you expect to happen

The old matcher's background goroutine and its cache should be cleaned up
when the folder is restarted or removed.

Reproduction / evidence

With CacheIgnoredFiles: true, instrumented a test that restarts a folder
50 times and counts goroutines before/after:

  • Before fix: goroutines increase by exactly 50 (one leaked per restart)
  • After fix (calling ignores.Stop() in cleanupFolderLocked before
    dropping the reference): delta is 0

On a long-running instance with frequent config edits or folder restarts,
this leaks a goroutine (and its cache map) per restart indefinitely.

Version

v2.1.2-16-g112895147

Syncthing version

v2.1.2-16-g112895147

Platform & operating system

macOS

Browser version

No response

Relevant log output

Activity

  1. added theissue type on Jul 21, 2026
  2. added
    bug
    needs-triage
    on Jul 21, 2026
  3. added a commit that references this issue on Jul 25, 2026
    b15ff42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions