Close process on fragment.openStorage error

When *fragment.openStorage is invoked in both f.importValue and
f.importValueSmallWrite and it returns an error, this means there's
some underlying error with the storage device and at the point of this
commit, the sane thing to do is to close the process, otherwise the
operation of Pilosa might proceed in an inconsistent state thus
precipiatting other silent but hairy errors along the way such as
dereferencing *fragment.gen later on which is set to nil once
openStorage fails.
This commit is contained in:
nagamocha3000 2021-02-01 20:23:34 +03:00
parent c75d5553b9
commit 92426a9d1b

View file

@ -2651,7 +2651,13 @@ func (f *fragment) importValueSmallWrite(tx Tx, columnIDs []uint64, values []int
}
return nil
}(); err != nil {
_ = f.openStorage(true)
errOpenStorage := f.openStorage(true)
if errOpenStorage != nil {
f.Logger.Printf("failed to import data into fragment: %v", err)
f.Logger.Printf("recovery with openStorage failed for fragment: %v", errOpenStorage)
f.Logger.Debugf("%s", debug.Stack())
os.Exit(1)
}
return err
}
rowSet := make(map[uint64]struct{}, bitDepth+1)
@ -2705,7 +2711,13 @@ func (f *fragment) importValue(tx Tx, columnIDs []uint64, values []int64, bitDep
// Flush changes in bulk back to the transaction.
return txb.Flush()
}(); err != nil {
_ = f.openStorage(true)
errOpenStorage := f.openStorage(true)
if errOpenStorage != nil {
f.Logger.Printf("failed to import data into fragment: %v", err)
f.Logger.Printf("recovery with openStorage failed for fragment: %v", errOpenStorage)
f.Logger.Debugf("%s", debug.Stack())
os.Exit(1)
}
return err
}
// Keep stats accurate. We don't call incrementOpN here because it may