[#1700] shard: Lock shard's mode mutex on close
All checks were successful
Pre-commit hooks / Pre-commit (push) Successful in 1m21s
Vulncheck / Vulncheck (push) Successful in 58s
Build / Build Components (push) Successful in 2m26s
Tests and linters / Run gofumpt (push) Successful in 2m19s
Tests and linters / Tests (push) Successful in 2m30s
Tests and linters / Staticcheck (push) Successful in 3m0s
Tests and linters / gopls check (push) Successful in 3m33s
Tests and linters / Lint (push) Successful in 3m45s
OCI image / Build container images (push) Successful in 4m54s
Tests and linters / Tests with -race (push) Successful in 6m28s
All checks were successful
Pre-commit hooks / Pre-commit (push) Successful in 1m21s
Vulncheck / Vulncheck (push) Successful in 58s
Build / Build Components (push) Successful in 2m26s
Tests and linters / Run gofumpt (push) Successful in 2m19s
Tests and linters / Tests (push) Successful in 2m30s
Tests and linters / Staticcheck (push) Successful in 3m0s
Tests and linters / gopls check (push) Successful in 3m33s
Tests and linters / Lint (push) Successful in 3m45s
OCI image / Build container images (push) Successful in 4m54s
Tests and linters / Tests with -race (push) Successful in 6m28s
To prevent race between GC handlers and close. Change-Id: I06219230964f000f666a56158d3563c760518c3b Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
fd37cea443
commit
f37babdc54
1 changed files with 9 additions and 4 deletions
|
@ -363,6 +363,7 @@ func (s *Shard) refillTombstoneObject(ctx context.Context, obj *objectSDK.Object
|
|||
|
||||
// Close releases all Shard's components.
|
||||
func (s *Shard) Close(ctx context.Context) error {
|
||||
unlock := s.lockExclusive()
|
||||
if s.rb != nil {
|
||||
s.rb.Stop(ctx, s.log)
|
||||
}
|
||||
|
@ -388,15 +389,19 @@ func (s *Shard) Close(ctx context.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
if s.opsLimiter != nil {
|
||||
s.opsLimiter.Close()
|
||||
}
|
||||
|
||||
unlock()
|
||||
|
||||
// GC waits for handlers and remover to complete. Handlers may try to lock shard's lock.
|
||||
// So to prevent deadlock GC stopping is outside of exclusive lock.
|
||||
// If Init/Open was unsuccessful gc can be nil.
|
||||
if s.gc != nil {
|
||||
s.gc.stop(ctx)
|
||||
}
|
||||
|
||||
if s.opsLimiter != nil {
|
||||
s.opsLimiter.Close()
|
||||
}
|
||||
|
||||
return lastErr
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue