{"record":{"id":"986e06c1ee93883d","repo":"hashicorp/nomad","slug":"failed-deleting-variable-entry-s","errorCode":null,"errorMessage":"failed deleting variable entry: %s","messagePattern":"failed deleting variable entry: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store_variables.go","lineNumber":434,"sourceCode":"\texistingQuota, err := tx.First(TableVariablesQuotas, indexID, req.Var.Namespace)\n\tif err != nil {\n\t\treturn req.ErrorResponse(idx, fmt.Errorf(\"variable quota lookup failed: %v\", err))\n\t}\n\n\t// Track quota usage\n\tif existingQuota != nil {\n\t\tquotaUsed := existingQuota.(*structs.VariablesQuota)\n\t\tquotaUsed = quotaUsed.Copy()\n\t\tquotaUsed.Size -= min(quotaUsed.Size, int64(len(sv.Data)))\n\t\tquotaUsed.ModifyIndex = idx\n\t\tif err := tx.Insert(TableVariablesQuotas, quotaUsed); err != nil {\n\t\t\treturn req.ErrorResponse(idx, fmt.Errorf(\"variable quota insert failed: %v\", err))\n\t\t}\n\t}\n\n\t// Delete the variable and update the index table.\n\tif err := tx.Delete(TableVariables, sv); err != nil {\n\t\treturn req.ErrorResponse(idx, fmt.Errorf(\"failed deleting variable entry: %s\", err))\n\t}\n\n\tif err := tx.Insert(tableIndex, &IndexEntry{TableVariables, idx}); err != nil {\n\t\treturn req.ErrorResponse(idx, fmt.Errorf(\"failed updating variable index: %s\", err))\n\t}\n\n\treturn req.SuccessResponse(idx, nil)\n}\n\n// WriteTxn is implemented by memdb.Txn to perform write operations.\ntype WriteTxn interface {\n\tReadTxn\n\tDefer(func())\n\tDelete(table string, obj any) error\n\tDeleteAll(table, index string, args ...any) (int, error)\n\tDeletePrefix(table string, index string, prefix string) (bool, error)\n\tInsert(table string, obj any) error\n}","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store_variables.go#L416-L452","documentation":"Returned by svDeleteTxn when tx.Delete(TableVariables, sv) fails while removing the variable's VariableEncrypted object from the state store. Quota and lookup steps succeeded, but the actual row deletion failed, aborting the transaction with an ErrorResponse.","triggerScenarios":"VarDelete / svDeleteCASTxn on an existing variable where tx.Delete on TableVariables errors — memdb refusing the delete (e.g. object no longer matches, txn aborted, internal failure).","commonSituations":"Concurrent modification racing the delete within the same txn scope in custom tooling; corrupted table; aborted txns under load.","solutions":["Read the wrapped %s error for the memdb cause","Retry the delete; aborting leaves the variable intact","Verify store integrity / restore from snapshot if recurring","Check for concurrent writers misusing the same txn"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed deleting variable entry\") {\n    // variable left intact; retry\n    return retryWithBackoff(deleteFn)\n}","preventionTips":["Retry deletes; aborts leave state consistent","Don't share txns across goroutines in tooling","Restore from snapshot only via supported procedures"],"tags":["nomad","state-store","memdb","variables","delete"],"backgroundTag":"memdb-delete-failed","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"}