File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -267,19 +267,28 @@ func (s *Store) emptyBranchWithParents(tx *bolt.Tx, id []byte) error {
267
267
if backlinks := tx .Bucket ([]byte (backlinksBucket )).Bucket (id ); backlinks != nil {
268
268
if err := backlinks .ForEach (func (k , v []byte ) error {
269
269
if subLinks := tx .Bucket ([]byte (linksBucket )).Bucket (k ); subLinks != nil {
270
+ // Perform deletion outside of the iteration.
271
+ // https://github.com/etcd-io/bbolt/pull/611
272
+ var toDelete []string
270
273
if err := subLinks .ForEach (func (k , v []byte ) error {
271
274
parts := bytes .Split (k , []byte ("@" ))
272
275
if len (parts ) != 2 {
273
276
return errors .Errorf ("invalid key %s" , k )
274
277
}
275
278
if bytes .Equal (id , parts [1 ]) {
276
- return subLinks . Delete ( k )
279
+ toDelete = append ( toDelete , string ( k ) )
277
280
}
278
281
return nil
279
282
}); err != nil {
280
283
return err
281
284
}
282
285
286
+ for _ , k := range toDelete {
287
+ if err := subLinks .Delete ([]byte (k )); err != nil {
288
+ return err
289
+ }
290
+ }
291
+
283
292
if isEmptyBucket (subLinks ) {
284
293
if subResult := tx .Bucket ([]byte (resultBucket )).Bucket (k ); isEmptyBucket (subResult ) {
285
294
if err := tx .Bucket ([]byte (linksBucket )).DeleteBucket (k ); err != nil {
You can’t perform that action at this time.
0 commit comments