forked from TrueCloudLab/frostfs-node
[#922] storage engine: Support operation blocking
There is a need to disable execution of local data operation on storage engine in runtime. If storage engine ops are blocked, node will act like always but all local object operations will be denied. Implement `BlockExecution` / `ResumeExecution` methods on `StorageEngine` which blocks / resumes the execution of data ops. Wait for the completion of all operations executed at the time of the call. Return error passed to `BlockExecution` from all data-related methods until `ResumeExecution` call. Make `Close` to block operations as well. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cea1de3a27
commit
ec04e787aa
10 changed files with 237 additions and 29 deletions
|
@ -49,7 +49,18 @@ var errInhumeFailure = errors.New("inhume operation failed")
|
|||
|
||||
// Inhume calls metabase. Inhume method to mark object as removed. It won't be
|
||||
// removed physically from shard until `Delete` operation.
|
||||
func (e *StorageEngine) Inhume(prm *InhumePrm) (*InhumeRes, error) {
|
||||
//
|
||||
// Returns an error if executions are blocked (see BlockExecution).
|
||||
func (e *StorageEngine) Inhume(prm *InhumePrm) (res *InhumeRes, err error) {
|
||||
err = e.exec(func() error {
|
||||
res, err = e.inhume(prm)
|
||||
return err
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (e *StorageEngine) inhume(prm *InhumePrm) (*InhumeRes, error) {
|
||||
if e.metrics != nil {
|
||||
defer elapsed(e.metrics.AddInhumeDuration)()
|
||||
}
|
||||
|
@ -63,9 +74,9 @@ func (e *StorageEngine) Inhume(prm *InhumePrm) (*InhumeRes, error) {
|
|||
shPrm.MarkAsGarbage(prm.addrs[i])
|
||||
}
|
||||
|
||||
ok := e.inhume(prm.addrs[i], shPrm, true)
|
||||
ok := e.inhumeAddr(prm.addrs[i], shPrm, true)
|
||||
if !ok {
|
||||
ok = e.inhume(prm.addrs[i], shPrm, false)
|
||||
ok = e.inhumeAddr(prm.addrs[i], shPrm, false)
|
||||
if !ok {
|
||||
return nil, errInhumeFailure
|
||||
}
|
||||
|
@ -75,7 +86,7 @@ func (e *StorageEngine) Inhume(prm *InhumePrm) (*InhumeRes, error) {
|
|||
return new(InhumeRes), nil
|
||||
}
|
||||
|
||||
func (e *StorageEngine) inhume(addr *objectSDK.Address, prm *shard.InhumePrm, checkExists bool) (ok bool) {
|
||||
func (e *StorageEngine) inhumeAddr(addr *objectSDK.Address, prm *shard.InhumePrm, checkExists bool) (ok bool) {
|
||||
root := false
|
||||
|
||||
e.iterateOverSortedShards(addr, func(_ int, sh *shard.Shard) (stop bool) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue