[#1412] metabase: Run bucket drop steps on upgrade concurrently

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-10-03 17:57:21 +03:00
parent 4716edc6a4
commit 653b3604e1

View file

@ -119,13 +119,17 @@ func upgradeFromV2ToV3(ctx context.Context, db *bbolt.DB, cs container.InfoProvi
if err := createExpirationEpochBuckets(ctx, db, log); err != nil {
return err
}
if err := dropUserAttributes(ctx, db, cs, log); err != nil {
return err
}
if err := dropOwnerIDIndex(ctx, db, log); err != nil {
return err
}
if err := dropPayloadChecksumIndex(ctx, db, log); err != nil {
eg, ctx := errgroup.WithContext(ctx)
eg.Go(func() error {
return dropUserAttributes(ctx, db, cs, log)
})
eg.Go(func() error {
return dropOwnerIDIndex(ctx, db, log)
})
eg.Go(func() error {
return dropPayloadChecksumIndex(ctx, db, log)
})
if err := eg.Wait(); err != nil {
return err
}
return db.Update(func(tx *bbolt.Tx) error {
@ -360,7 +364,7 @@ func dropUserAttributes(ctx context.Context, db *bbolt.DB, cs container.InfoProv
if err != nil {
return err
}
if err := db.Update(func(tx *bbolt.Tx) error {
if err := db.Batch(func(tx *bbolt.Tx) error {
for _, k := range keysToDrop {
if err := tx.DeleteBucket(k); err != nil {
return err
@ -439,7 +443,7 @@ func dropBucketsByPrefix(ctx context.Context, db *bbolt.DB, prefix []byte, log f
log("deleting buckets completed successfully, deleted", count, "buckets")
return nil
}
if err := db.Update(func(tx *bbolt.Tx) error {
if err := db.Batch(func(tx *bbolt.Tx) error {
for _, k := range keys {
if err := tx.DeleteBucket(k); err != nil {
return err