forked from TrueCloudLab/frostfs-node
[#1624] blobovniczatree: Return source error from Init()
As it was before: when the database was opened, an error returned, but along with the original error, the `context cancelled`` error returned, because `iterateIncompletedRebuildDBPaths` method has `ctx.Done()` check and egCtx passed to `iterateIncompletedRebuildDBPaths` method. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
9c4c5a5262
commit
4de5fca547
2 changed files with 60 additions and 27 deletions
|
@ -41,35 +41,34 @@ func (b *Blobovniczas) initializeDBs(ctx context.Context) error {
|
|||
}
|
||||
|
||||
eg, egCtx := errgroup.WithContext(ctx)
|
||||
eg.SetLimit(b.blzInitWorkerCount)
|
||||
err = b.iterateIncompletedRebuildDBPaths(egCtx, func(p string) (bool, error) {
|
||||
eg.Go(func() error {
|
||||
p = strings.TrimSuffix(p, rebuildSuffix)
|
||||
shBlz := b.getBlobovniczaWithoutCaching(p)
|
||||
blz, err := shBlz.Open(egCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer shBlz.Close(egCtx)
|
||||
|
||||
moveInfo, err := blz.ListMoveInfo(egCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, move := range moveInfo {
|
||||
b.deleteProtectedObjects.Add(move.Address)
|
||||
}
|
||||
|
||||
b.log.Debug(egCtx, logs.BlobovniczatreeBlobovniczaSuccessfullyInitializedClosing, zap.String("id", p))
|
||||
return nil
|
||||
})
|
||||
return false, nil
|
||||
})
|
||||
if err != nil {
|
||||
_ = eg.Wait()
|
||||
return err
|
||||
if b.blzInitWorkerCount > 0 {
|
||||
eg.SetLimit(b.blzInitWorkerCount + 1)
|
||||
}
|
||||
eg.Go(func() error {
|
||||
return b.iterateIncompletedRebuildDBPaths(egCtx, func(p string) (bool, error) {
|
||||
eg.Go(func() error {
|
||||
p = strings.TrimSuffix(p, rebuildSuffix)
|
||||
shBlz := b.getBlobovniczaWithoutCaching(p)
|
||||
blz, err := shBlz.Open(egCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer shBlz.Close(egCtx)
|
||||
|
||||
moveInfo, err := blz.ListMoveInfo(egCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, move := range moveInfo {
|
||||
b.deleteProtectedObjects.Add(move.Address)
|
||||
}
|
||||
|
||||
b.log.Debug(egCtx, logs.BlobovniczatreeBlobovniczaSuccessfullyInitializedClosing, zap.String("id", p))
|
||||
return nil
|
||||
})
|
||||
return false, nil
|
||||
})
|
||||
})
|
||||
return eg.Wait()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue