{"record":{"id":"f2f9c8217b568c45","repo":"grafana/k6","slug":"maxvus-can-t-be-less-than-preallocatedvus","errorCode":null,"errorMessage":"maxVUs can't be less than preAllocatedVUs","messagePattern":"maxVUs can't be less than preAllocatedVUs","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/constant_arrival_rate.go","lineNumber":121,"sourceCode":"\tif !carc.Duration.Valid {\n\t\terrors = append(errors, fmt.Errorf(\"the duration is unspecified\"))\n\t} else if carc.Duration.TimeDuration() < minDuration {\n\t\terrors = append(errors, fmt.Errorf(\n\t\t\t\"the duration must be at least %s, but is %s\", minDuration, carc.Duration,\n\t\t))\n\t}\n\n\tif !carc.PreAllocatedVUs.Valid {\n\t\terrors = append(errors, fmt.Errorf(\"the number of preAllocatedVUs isn't specified\"))\n\t} else if carc.PreAllocatedVUs.Int64 < 0 {\n\t\terrors = append(errors, fmt.Errorf(\"the number of preAllocatedVUs can't be negative\"))\n\t}\n\n\tif !carc.MaxVUs.Valid {\n\t\t// TODO: don't change the config while validating\n\t\tcarc.MaxVUs.Int64 = carc.PreAllocatedVUs.Int64\n\t} else if carc.MaxVUs.Int64 < carc.PreAllocatedVUs.Int64 {\n\t\terrors = append(errors, fmt.Errorf(\"maxVUs can't be less than preAllocatedVUs\"))\n\t}\n\n\treturn errors\n}\n\n// GetExecutionRequirements returns the number of required VUs to run the\n// executor for its whole duration (disregarding any startTime), including the\n// maximum waiting time for any iterations to gracefully stop. This is used by\n// the execution scheduler in its VU reservation calculations, so it knows how\n// many VUs to pre-initialize.\nfunc (carc ConstantArrivalRateConfig) GetExecutionRequirements(et *lib.ExecutionTuple) []lib.ExecutionStep {\n\treturn []lib.ExecutionStep{\n\t\t{\n\t\t\tTimeOffset:      0,\n\t\t\tPlannedVUs:      uint64(et.ScaleInt64(carc.PreAllocatedVUs.Int64)),                                    //nolint:gosec\n\t\t\tMaxUnplannedVUs: uint64(et.ScaleInt64(carc.MaxVUs.Int64) - et.ScaleInt64(carc.PreAllocatedVUs.Int64)), //nolint:gosec\n\t\t}, {\n\t\t\tTimeOffset:      carc.Duration.TimeDuration() + carc.GracefulStop.TimeDuration(),","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/executor/constant_arrival_rate.go#L103-L139","documentation":"ConstantArrivalRateConfig.Validate found maxVUs smaller than preAllocatedVUs. All pre-allocated VUs count toward maxVUs (the hard ceiling), so preAllocatedVUs > maxVUs is contradictory and rejected before the run starts.","triggerScenarios":"Thrown at lib/executor/constant_arrival_rate.go:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set maxVUs >= preAllocatedVUs, e.g. preAllocatedVUs: 10, maxVUs: 100","Give headroom in maxVUs if you expect the arrival rate to need more VUs than pre-allocated"],"exampleFix":null,"handlingStrategy":"validation","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"}