yowcow / goromdb

Yet another single process KVS server implemented over file-based database
The Unlicense
12 stars 5 forks source link

Get op on storage should RLock first, then get pointer to db handle #81

Closed yowcow closed 6 years ago

yowcow commented 6 years ago

In current sequence of storage Get op:

  1. get pointer to db handle
  2. get read-lock
  3. query db

if db is reloaded between step 1 and 2, retrieved pointer to db is unusable at step 3.

To fix this problem, the sequence should be:

  1. get read-lock
  2. get pointer to db
  3. query db
yowcow commented 6 years ago

Confirmed in boltstorage.

bdbstorage has different issue that it does Lock, not RLock, in Get operation.