Files
rclone/fs
Sanjays2402 c91c4cbbff accounting: fix goroutine leak in NewStatsGroup for zero-transfer rc jobs
NewStatsGroup started the averageLoop goroutine unconditionally at
group creation. In an rcd daemon driven by many short rc sync/move
calls (a common pattern for scheduled spool flushes), each call gets
a fresh job/N stats group. When such a job transferred zero files
the loop was never stopped, because _stopAverageLoop is only reached
via DoneTransferring once transferring and checking both go from
non-empty back to empty, which never happens if nothing was ever
transferring in the first place. The result was one leaked goroutine
per rc call, growing unbounded until the daemon was OOM-killed
(reported: ~61k goroutines and ~640 MB RSS after ~7 days from a
per-minute timer over 6 mappings).

This is the same class of leak as #8571, which fixed the equivalent
auto-start in NewStats. Fix it the same way: do not start the average
loop at group creation. NewTransfer and NewTransferRemoteSize already
call startAverageLoop when real transfer activity begins, and
DoneTransferring already stops it when the last transfer completes,
so on-demand behaviour is unchanged for groups that actually do work.
Groups that never transfer anything now cost zero goroutines.

Adds a regression test that fails without the fix.

Fixes #9567
2026-07-02 11:15:18 +01:00
..
2025-02-28 11:31:14 +00:00
2025-02-28 11:31:14 +00:00
2025-09-15 12:45:57 +01:00
2025-10-21 18:56:06 +01:00
2026-06-15 08:14:03 +02:00
2025-10-21 18:56:06 +01:00
2025-02-28 11:31:14 +00:00
2023-10-23 15:43:55 +01:00
2018-08-21 10:58:59 +01:00
2025-11-03 14:44:39 +00:00
2026-04-24 17:20:18 +01:00
2026-05-01 17:15:20 +01:00