code: func (b *batch) run() {
  	b.db.batchMu.Lock()
  	b.timer.Stop()
  	// Make sure no new work is added to this batch, but don't break
  	// other batches.
  	if b.db.batch == b {
  		b.db.batch = nil
  	}
  	b.db.batchMu.Unlock()
  
  retry:
  	for len(b.calls) > 0 {
  		var failIdx = -1
  		err := b.db.Update(func(tx *Tx) error {
  			for i, c := range b.calls {
  				if err := safelyCall(c.fn, tx); err != nil {
  					failIdx = i
  					return err
  				}
  			}
  			return nil
  		})
  
  		if failIdx >= 0 {
  			// take the failing transaction out of the batch. it's
  			// safe to shorten b.calls here because db.batch no longer
  			// points to us, and we hold the mutex anyway.
  			c := b.calls[failIdx]
  			b.calls[failIdx], b.calls = b.calls[len(b.calls)-1], b.calls[:len(b.calls)-1]
  			// tell the submitter re-run it solo, continue with the rest of the batch
  			c.err <- trySolo
  			continue retry
  		}
  
  		// pass success, or bolt internal errors, to all callers
  		for _, c := range b.calls {
  			c.err <- err
  		}
  		break retry
  	}
  }
docs: // run performs the transactions in the batch and communicates results
  // back to DB.Batch.