frostfs-node/pkg
Alex Vanin e6f2d84736 [#246] blobovnivza: Fix deadlock on concurrent evict and open new blobovnicza
Deadlock occurs when `getActivate` function opens new blobovnicza and that
invokes evict in LRU cache of open blobovniczas. `getActivate` makes
`activeMtx.Lock()` and then cache evict makes `activeMtx.RLock()` and deadlock
happens.

Fix contains two steps:
- add separate mutex to open blobovniczas (1),
- split single Lock outside of `updateAndGet` (2).

As for the (1) `bbolt.Open()` locks when it tries to open the same file from
two threads. So separate mutex will prevent that.

As for the (2) `updateAndGet` function contains from two parts. At first it
checks if required blobovnicza is ready and it returns it. In this case we can
use the simple RLock. But then there is an option when we should open new
blobovnicza and update map of active blobovniczas.

In this case we call `openBlobovnicza` without activeMtx lock. Cache evict
happens there and it won't cause deadlock.

Then we lock activeMtx to update the map of active blobovniczas. Concurrency can
happen there. However `openBlobovnicza` will not open the same blobovnicza twice,
so we can make one more check if opened blobovnicza was activated while thread was
locked in activeMtx. If so, then return active blobovnicza, else finish activation.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-14 13:37:45 +03:00
..
core [#243] core/object: Replace test content of tombstone with an API structure 2020-12-11 17:19:37 +03:00
innerring [#170] Invoke all alphabet contracts for voting 2020-12-10 17:22:37 +03:00
local_object_storage [#246] blobovnivza: Fix deadlock on concurrent evict and open new blobovnicza 2020-12-14 13:37:45 +03:00
morph [#170] morph/client: Print reversed hash in logs 2020-12-10 17:22:37 +03:00
network [#241] object/search: Refactor service processing 2020-12-11 17:19:37 +03:00
policy [#155] Update neofs-api-go with refactored pkg/netmap 2020-11-06 09:55:05 +03:00
services [#243] services/object: Share common parameters across services 2020-12-11 17:19:37 +03:00
util [#174] Use Marshal(JSON)/Unmarshal(JSON) methods for encoding/decoding 2020-11-17 11:56:00 +03:00