grafana/k6 · error

could not get a VU from the buffer in %s

Error message

could not get a VU from the buffer in %s

What it means

GetPlannedVU retried MaxRetriesGetPlannedVU times to pull a VU from the execution state's buffered channel but the buffer stayed empty every time. This is an internal executor bookkeeping failure — a reserved VU was expected to be available but wasn't returned within the retry window.

Source

Thrown at lib/execution.go:485

// If modifyActiveVUCount is true, the method would also increment the counter
// for active VUs. In most cases, that's the desired behavior, but some
// executors might have to retrieve their reserved VUs without using them
// immediately - for example, the externally-controlled executor when the
// configured maxVUs number is greater than the configured starting VUs.
func (es *ExecutionState) GetPlannedVU(logger *logrus.Entry, modifyActiveVUCount bool) (InitializedVU, error) {
	for i := 1; i <= MaxRetriesGetPlannedVU; i++ {
		select {
		case vu := <-es.vus:
			if modifyActiveVUCount {
				es.ModCurrentlyActiveVUsCount(+1)
			}
			// TODO: set environment and exec
			return vu, nil
		case <-time.After(MaxTimeToWaitForPlannedVU):
			logger.Warnf("Could not get a VU from the buffer for %s", time.Duration(i)*MaxTimeToWaitForPlannedVU)
		}
	}
	return nil, fmt.Errorf(
		"could not get a VU from the buffer in %s",
		MaxRetriesGetPlannedVU*MaxTimeToWaitForPlannedVU,
	)
}

// SetInitVUFunc is called by the execution scheduler's init function, and it's
// used for setting the "constructor" function used for the initializing
// unplanned VUs.
//
// TODO: figure out a better dependency injection method?
func (es *ExecutionState) SetInitVUFunc(initVUFunc InitVUFunc) {
	es.initVUFunc = initVUFunc
}

// GetUnplannedVU checks if any unplanned VUs remain to be initialized, and if
// they do, it initializes one and returns it. If all unplanned VUs have already
// been initialized, it returns one from the global vus buffer, but doesn't
// automatically increment the active VUs counter in either case.

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Check executor configuration for inconsistent maxVUs/preAllocatedVUs settings that could starve the VU buffer
  2. Report suspected k6 bugs at https://github.com/grafana/k6/issues with the executor options and script
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at lib/execution.go:485 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/4a94b12ca69e2475. Report an issue: GitHub.