forked from TrueCloudLab/frostfs-node
[#1944] metabase: Assume static buckets are created on Init
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
e4bc3d0e9d
commit
7395ab8ef7
7 changed files with 7 additions and 35 deletions
|
@ -25,6 +25,7 @@ Changelog for NeoFS Node
|
|||
- Inability to provide session to NeoFS CLI in a NeoFS-binary format (#1933)
|
||||
- `neofs-adm` now works correctly with a committee of more than 4 nodes (#1949, #1959)
|
||||
- Closing a shard now waits until GC background workers stop (#1964)
|
||||
- Make it possible to use `shard.ContainerSize` in read-only mode (#1975)
|
||||
|
||||
### Removed
|
||||
### Updated
|
||||
|
|
|
@ -38,7 +38,7 @@ func (db *DB) containers(tx *bbolt.Tx) ([]cid.ID, error) {
|
|||
}
|
||||
|
||||
func (db *DB) ContainerSize(id cid.ID) (size uint64, err error) {
|
||||
err = db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||
err = db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
size, err = db.containerSize(tx, id)
|
||||
|
||||
return err
|
||||
|
@ -48,11 +48,7 @@ func (db *DB) ContainerSize(id cid.ID) (size uint64, err error) {
|
|||
}
|
||||
|
||||
func (db *DB) containerSize(tx *bbolt.Tx, id cid.ID) (uint64, error) {
|
||||
containerVolume, err := tx.CreateBucketIfNotExists(containerVolumeBucketName)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
containerVolume := tx.Bucket(containerVolumeBucketName)
|
||||
key := make([]byte, cidSize)
|
||||
id.Encode(key)
|
||||
|
||||
|
@ -78,11 +74,7 @@ func parseContainerSize(v []byte) uint64 {
|
|||
}
|
||||
|
||||
func changeContainerSize(tx *bbolt.Tx, id cid.ID, delta uint64, increase bool) error {
|
||||
containerVolume, err := tx.CreateBucketIfNotExists(containerVolumeBucketName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
containerVolume := tx.Bucket(containerVolumeBucketName)
|
||||
key := make([]byte, cidSize)
|
||||
id.Encode(key)
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ func (db *DB) init(reset bool) error {
|
|||
string(toMoveItBucketName): {},
|
||||
string(garbageBucketName): {},
|
||||
string(shardInfoBucket): {},
|
||||
string(bucketNameLocked): {},
|
||||
}
|
||||
|
||||
return db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||
|
|
|
@ -164,10 +164,6 @@ func (db *DB) iterateDeletedObj(tx *bbolt.Tx, h kvHandler, offset *oid.Address)
|
|||
panic(fmt.Sprintf("metabase: unknown iteration object hadler: %T", t))
|
||||
}
|
||||
|
||||
if bkt == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
c := bkt.Cursor()
|
||||
var k, v []byte
|
||||
|
||||
|
|
|
@ -125,9 +125,6 @@ func (db *DB) IterateCoveredByTombstones(tss map[string]oid.Address, h func(oid.
|
|||
|
||||
func (db *DB) iterateCoveredByTombstones(tx *bbolt.Tx, tss map[string]oid.Address, h func(oid.Address) error) error {
|
||||
bktGraveyard := tx.Bucket(graveyardBucketName)
|
||||
if bktGraveyard == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := bktGraveyard.ForEach(func(k, v []byte) error {
|
||||
var addr oid.Address
|
||||
|
|
|
@ -44,10 +44,7 @@ func (db *DB) Lock(cnr cid.ID, locker oid.ID, locked []oid.ID) error {
|
|||
return apistatus.LockNonRegularObject{}
|
||||
}
|
||||
|
||||
bucketLocked, err := tx.CreateBucketIfNotExists(bucketNameLocked)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create global bucket for locked objects: %w", err)
|
||||
}
|
||||
bucketLocked := tx.Bucket(bucketNameLocked)
|
||||
|
||||
cnr.Encode(key)
|
||||
bucketLockedContainer, err := bucketLocked.CreateBucketIfNotExists(key)
|
||||
|
|
|
@ -56,11 +56,7 @@ func (db *DB) ToMoveIt(prm ToMoveItPrm) (res ToMoveItRes, err error) {
|
|||
key = addressKey(prm.addr, key)
|
||||
|
||||
err = db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||
toMoveIt, err := tx.CreateBucketIfNotExists(toMoveItBucketName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
toMoveIt := tx.Bucket(toMoveItBucketName)
|
||||
return toMoveIt.Put(key, zeroValue)
|
||||
})
|
||||
|
||||
|
@ -77,10 +73,6 @@ func (db *DB) DoNotMove(prm DoNotMovePrm) (res DoNotMoveRes, err error) {
|
|||
|
||||
err = db.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||
toMoveIt := tx.Bucket(toMoveItBucketName)
|
||||
if toMoveIt == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return toMoveIt.Delete(key)
|
||||
})
|
||||
|
||||
|
@ -96,10 +88,6 @@ func (db *DB) Movable(_ MovablePrm) (MovableRes, error) {
|
|||
|
||||
err := db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
toMoveIt := tx.Bucket(toMoveItBucketName)
|
||||
if toMoveIt == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return toMoveIt.ForEach(func(k, v []byte) error {
|
||||
strAddrs = append(strAddrs, string(k))
|
||||
|
||||
|
|
Loading…
Reference in a new issue