[#602] blobovnicza: Init before using
Fix blobovnicza size: after restart size metric resets. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
f7042c5a6f
commit
2e49d7ea7e
2 changed files with 20 additions and 17 deletions
|
@ -45,8 +45,6 @@ func (b *Blobovnicza) Open() error {
|
|||
// Init initializes internal database structure.
|
||||
//
|
||||
// If Blobovnicza is already initialized, no action is taken.
|
||||
//
|
||||
// Should not be called in read-only configuration.
|
||||
func (b *Blobovnicza) Init() error {
|
||||
b.log.Debug(logs.BlobovniczaInitializing,
|
||||
zap.Uint64("object size limit", b.objSizeLimit),
|
||||
|
@ -58,6 +56,7 @@ func (b *Blobovnicza) Init() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if !b.boltOptions.ReadOnly {
|
||||
err := b.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||
return b.iterateBucketKeys(func(lower, upper uint64, key []byte) (bool, error) {
|
||||
// create size range bucket
|
||||
|
@ -78,6 +77,7 @@ func (b *Blobovnicza) Init() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
info, err := os.Stat(b.path)
|
||||
if err != nil {
|
||||
|
|
|
@ -136,5 +136,8 @@ func (b *Blobovniczas) openBlobovniczaNoCache(p string) (*blobovnicza.Blobovnicz
|
|||
if err := blz.Open(); err != nil {
|
||||
return nil, fmt.Errorf("could not open blobovnicza %s: %w", p, err)
|
||||
}
|
||||
if err := blz.Init(); err != nil {
|
||||
return nil, fmt.Errorf("could not init blobovnicza %s: %w", p, err)
|
||||
}
|
||||
return blz, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue