{"record":{"id":"de03799c3bb1383a","repo":"hashicorp/nomad","slug":"failed-inserting-variable-s","errorCode":null,"errorMessage":"failed inserting variable: %s","messagePattern":"failed inserting variable: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store_variables.go","lineNumber":249,"sourceCode":"\n\t\tif existing.Equal(*sv) {\n\t\t\t// Skip further writing in the state store if the entry is not actually\n\t\t\t// changed. Nevertheless, the input's ModifyIndex should be reset\n\t\t\t// since the TXN API returns a copy in the response.\n\t\t\tsv.ModifyIndex = existing.ModifyIndex\n\t\t\tsv.ModifyTime = existing.ModifyTime\n\t\t\treturn req.SuccessResponse(idx, nil)\n\t\t}\n\t\tsv.ModifyIndex = idx\n\t\tquotaChange = int64(len(sv.Data) - len(existing.Data))\n\t} else {\n\t\tsv.CreateIndex = idx\n\t\tsv.ModifyIndex = idx\n\t\tquotaChange = int64(len(sv.Data))\n\t}\n\n\tif err := tx.Insert(TableVariables, sv); err != nil {\n\t\treturn req.ErrorResponse(idx, fmt.Errorf(\"failed inserting variable: %s\", err))\n\t}\n\n\t// Track quota usage\n\tvar quotaUsed *structs.VariablesQuota\n\tif existingQuota != nil {\n\t\tquotaUsed = existingQuota.(*structs.VariablesQuota)\n\t\tquotaUsed = quotaUsed.Copy()\n\t} else {\n\t\tquotaUsed = &structs.VariablesQuota{\n\t\t\tNamespace:   sv.Namespace,\n\t\t\tCreateIndex: idx,\n\t\t}\n\t}\n\n\tif quotaChange > math.MaxInt64-quotaUsed.Size {\n\t\t// this limit is actually shared across all namespaces in the region's\n\t\t// quota (if there is one), but we need this check here to prevent\n\t\t// overflow as well","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store_variables.go#L231-L267","documentation":"Inserting the variable into the variables table failed in memdb; the wrapped tx.Insert error aborts the variable set after quota accounting.","triggerScenarios":"Thrown at nomad/state/state_store_variables.go:249 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the variable write","Check server logs for state store write errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}