rclone/fs/accounting
Nick Craig-Wood f5439ddc54 accounting: fix deadlock in stats printing
The deadlock was caused in transfermap.go by calling mu.RLock() in one
function then calling it again in a sub function. Normally this is
fine, however this leaves a window where mu.Lock() can be called. When
mu.Lock() is called it doesn't allow the second mu.RLock() and
deadlocks.

    Thead 1                    Thread 2
    String():mu.RLock()
                               del():mu.Lock()
    sortedSlice():mu.RLock()                     - DEADLOCK

Lesson learnt: don't try using locks recursively ever!

This patch fixes the problem by removing the second mu.RLock(). This
was done by factoring the code that was calling it into the
transfermap.go file so all the locking can be seen at once which was
ultimately the cause of the problem - the code which used the locks
was too far away from the rest of the code using the lock.

This problem was introduced in:

bfa5715017 fs/accounting: sort transfers by start time

Which hasn't been released in a stable version yet
2020-08-05 17:13:00 +01:00
..
accounting.go accounting: fix deadlock in stats printing 2020-08-05 17:13:00 +01:00
accounting_other.go Break the fs package up into smaller parts. 2018-01-15 17:51:14 +00:00
accounting_test.go accounting: Allow transfers to be canceled with context #3257 2020-07-28 16:41:17 +01:00
accounting_unix.go build: fix up package paths after repo move 2019-07-28 18:47:38 +01:00
inprogress.go build: fix up package paths after repo move 2019-07-28 18:47:38 +01:00
prometheus.go rcd: fix incorrect prometheus metrics - fixes #4341 2020-06-14 10:09:24 +01:00
stats.go accounting: fix deadlock in stats printing 2020-08-05 17:13:00 +01:00
stats_groups.go accounting: Fix elapsed time not show actual time since beginning 2020-07-26 11:59:50 +01:00
stats_groups_test.go test: Don't run unreliable tests on CI #4171 2020-06-15 21:34:37 +01:00
stats_test.go fs/accounting: add option to delete stats 2020-01-03 17:44:05 +00:00
token_bucket.go doc: fix typos throughout docs 2020-05-19 12:02:44 +01:00
token_bucket_test.go build: fix up package paths after repo move 2019-07-28 18:47:38 +01:00
transfer.go accounting: fix deadlock in stats printing 2020-08-05 17:13:00 +01:00
transfermap.go accounting: fix deadlock in stats printing 2020-08-05 17:13:00 +01:00