Files
Brad Fitzpatrick a6cffd0a6d drive/driveimpl/compositedav: don't run ttlcache cleanup goroutines
StatCache started each ttlcache with "go cache.Start()" and stopped
them in StatCache.stop. But ttlcache caches begin in the stopped
state, so if stop ran before the Start goroutine was scheduled,
Stop was a no-op and Start then ran forever, leaking a goroutine.
That made tests using tstest.ResourceCheck flaky:

    goroutine github.com/jellydator/ttlcache/v3.(*Cache[...]).Start

Rather than synchronize with Start, drop the background goroutine
entirely. Cache.Get already ignores expired items, so the goroutine
only existed to free memory. Instead, call DeleteExpired on each
write, which is cheap: it pops expired entries from the front of the
expiration heap and stops at the first unexpired one. With no
goroutines, StatCache.stop is no longer needed, so remove it.

Fixes #21824
Updates tailscale/corp#49459

Change-Id: Ib438fcd45296be79528613c5f5687725c38a137d
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-10-23 20:41:40 -04:00
..
2026-07-10 17:39:16 -07:00
2026-07-10 17:39:16 -07:00