code: func (bk *Backend) AcquireLock(token string, ttl time.Duration) (err error) {
  	bk.log.Debugf("AcquireLock(%s)", token)
  
  	if err = legacy.ValidateLockTTL(ttl); err != nil {
  		return trace.Wrap(err)
  	}
  
  	bucket := []string{locksBucket}
  	for {
  		// GetVal will clear TTL on a lock
  		bk.GetVal(bucket, token)
  
  		// CreateVal is atomic:
  		err = bk.CreateVal(bucket, token, []byte{1}, ttl)
  		if err == nil {
  			break // success
  		}
  		if trace.IsAlreadyExists(err) { // locked? wait and repeat:
  			bk.Clock().Sleep(250 * time.Millisecond)
  			continue
  		}
  		return trace.ConvertSystemError(err)
  	}
  
  	return nil
  }
docs: // AcquireLock grabs a lock that will be released automatically in TTL.