frostfs-node/pkg/local_object_storage
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
..
blobovnicza [#245] blobovnicza: Fix initializing dimensional buckets 2020-12-14 12:48:59 +03:00
blobstor [#246] blobovnivza: Fix deadlock on concurrent evict and open new blobovnicza 2020-12-14 13:37:45 +03:00
bucket [#136] cmd/neofs-node: Use new metabase in app 2020-11-03 18:42:32 +03:00
engine [#242] engine: Do not iterate over shards if cid is not set 2020-12-11 17:19:37 +03:00
metabase [#242] metabase: Make ContainerID a mandatory parameter for Select 2020-12-11 17:19:37 +03:00
shard [#242] shard: Support ContainerID argument in metabase selects 2020-12-11 17:19:37 +03:00