File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 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 {
267267 if backlinks := tx .Bucket ([]byte (backlinksBucket )).Bucket (id ); backlinks != nil {
268268 if err := backlinks .ForEach (func (k , v []byte ) error {
269269 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
270273 if err := subLinks .ForEach (func (k , v []byte ) error {
271274 parts := bytes .Split (k , []byte ("@" ))
272275 if len (parts ) != 2 {
273276 return errors .Errorf ("invalid key %s" , k )
274277 }
275278 if bytes .Equal (id , parts [1 ]) {
276- return subLinks . Delete ( k )
279+ toDelete = append ( toDelete , string ( k ) )
277280 }
278281 return nil
279282 }); err != nil {
280283 return err
281284 }
282285
286+ for _ , k := range toDelete {
287+ if err := subLinks .Delete ([]byte (k )); err != nil {
288+ return err
289+ }
290+ }
291+
283292 if isEmptyBucket (subLinks ) {
284293 if subResult := tx .Bucket ([]byte (resultBucket )).Bucket (k ); isEmptyBucket (subResult ) {
285294 if err := tx .Bucket ([]byte (linksBucket )).DeleteBucket (k ); err != nil {
You can’t perform that action at this time.
0 commit comments