forked from TrueCloudLab/frostfs-node
[#1686] shard: Open all components in case metabase has failed
All components must be opened first, before any other operation is performed. Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
c7c1c257e1
commit
bc20851cd1
1 changed files with 9 additions and 1 deletions
|
@ -50,9 +50,17 @@ func (s *Shard) Open() error {
|
||||||
components = append(components, s.pilorama)
|
components = append(components, s.pilorama)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, component := range components {
|
for i, component := range components {
|
||||||
if err := component.Open(false); err != nil {
|
if err := component.Open(false); err != nil {
|
||||||
if component == s.metaBase {
|
if component == s.metaBase {
|
||||||
|
// We must first open all other components to avoid
|
||||||
|
// opening non-existent DB in read-only mode.
|
||||||
|
for j := i + 1; j < len(components); j++ {
|
||||||
|
if err := components[j].Open(false); err != nil {
|
||||||
|
// Other components must be opened, fail.
|
||||||
|
return fmt.Errorf("could not open %T: %w", components[j], err)
|
||||||
|
}
|
||||||
|
}
|
||||||
err = s.handleMetabaseFailure("open", err)
|
err = s.handleMetabaseFailure("open", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue