[#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:
Leonard Lyubich 2021-11-09 18:46:12 +03:00 committed by Alex Vanin
parent cea1de3a27
commit ec04e787aa
10 changed files with 237 additions and 29 deletions

View file

@ -33,7 +33,18 @@ func (p *PutPrm) WithObject(obj *object.Object) *PutPrm {
//
// Returns any error encountered that
// did not allow to completely save the object.
func (e *StorageEngine) Put(prm *PutPrm) (*PutRes, error) {
//
// Returns an error if executions are blocked (see BlockExecution).
func (e *StorageEngine) Put(prm *PutPrm) (res *PutRes, err error) {
err = e.exec(func() error {
res, err = e.put(prm)
return err
})
return
}
func (e *StorageEngine) put(prm *PutPrm) (*PutRes, error) {
if e.metrics != nil {
defer elapsed(e.metrics.AddPutDuration)()
}