{"record":{"id":"4a94b12ca69e2475","repo":"grafana/k6","slug":"could-not-get-a-vu-from-the-buffer-in-s","errorCode":null,"errorMessage":"could not get a VU from the buffer in %s","messagePattern":"could not get a VU from the buffer in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/execution.go","lineNumber":485,"sourceCode":"// If modifyActiveVUCount is true, the method would also increment the counter\n// for active VUs. In most cases, that's the desired behavior, but some\n// executors might have to retrieve their reserved VUs without using them\n// immediately - for example, the externally-controlled executor when the\n// configured maxVUs number is greater than the configured starting VUs.\nfunc (es *ExecutionState) GetPlannedVU(logger *logrus.Entry, modifyActiveVUCount bool) (InitializedVU, error) {\n\tfor i := 1; i <= MaxRetriesGetPlannedVU; i++ {\n\t\tselect {\n\t\tcase vu := <-es.vus:\n\t\t\tif modifyActiveVUCount {\n\t\t\t\tes.ModCurrentlyActiveVUsCount(+1)\n\t\t\t}\n\t\t\t// TODO: set environment and exec\n\t\t\treturn vu, nil\n\t\tcase <-time.After(MaxTimeToWaitForPlannedVU):\n\t\t\tlogger.Warnf(\"Could not get a VU from the buffer for %s\", time.Duration(i)*MaxTimeToWaitForPlannedVU)\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\n\t\t\"could not get a VU from the buffer in %s\",\n\t\tMaxRetriesGetPlannedVU*MaxTimeToWaitForPlannedVU,\n\t)\n}\n\n// SetInitVUFunc is called by the execution scheduler's init function, and it's\n// used for setting the \"constructor\" function used for the initializing\n// unplanned VUs.\n//\n// TODO: figure out a better dependency injection method?\nfunc (es *ExecutionState) SetInitVUFunc(initVUFunc InitVUFunc) {\n\tes.initVUFunc = initVUFunc\n}\n\n// GetUnplannedVU checks if any unplanned VUs remain to be initialized, and if\n// they do, it initializes one and returns it. If all unplanned VUs have already\n// been initialized, it returns one from the global vus buffer, but doesn't\n// automatically increment the active VUs counter in either case.","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/execution.go#L467-L503","documentation":"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.","triggerScenarios":"Thrown at lib/execution.go:485 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check executor configuration for inconsistent maxVUs/preAllocatedVUs settings that could starve the VU buffer","Report suspected k6 bugs at https://github.com/grafana/k6/issues with the executor options and script"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}