{"record":{"id":"e6db9e90ea5fb38c","repo":"hashicorp/nomad","slug":"node-not-found-s-e6db9e","errorCode":null,"errorMessage":"node not found: %s","messagePattern":"node not found: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":1080,"sourceCode":"\terr := s.deleteNodeTxn(txn, index, nodes)\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn txn.Commit()\n}\n\nfunc (s *StateStore) deleteNodeTxn(txn *txn, index uint64, nodes []string) error {\n\tif len(nodes) == 0 {\n\t\treturn fmt.Errorf(\"node ids missing\")\n\t}\n\n\tfor _, nodeID := range nodes {\n\t\texisting, err := txn.First(\"nodes\", \"id\", nodeID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"node lookup failed: %s: %v\", nodeID, err)\n\t\t}\n\t\tif existing == nil {\n\t\t\treturn fmt.Errorf(\"node not found: %s\", nodeID)\n\t\t}\n\n\t\t// Delete the node\n\t\tif err := txn.Delete(\"nodes\", existing); err != nil {\n\t\t\treturn fmt.Errorf(\"node delete failed: %s: %v\", nodeID, err)\n\t\t}\n\n\t\tnode := existing.(*structs.Node)\n\t\tif err := deleteNodeCSIPlugins(txn, node, index); err != nil {\n\t\t\treturn fmt.Errorf(\"csi plugin delete failed: %v\", err)\n\t\t}\n\t\tif node.GCVolumesOnNodeGC {\n\t\t\tif err := s.deleteHostVolumesOnNode(txn, index, node.ID); err != nil {\n\t\t\t\treturn fmt.Errorf(\"dynamic host volume delete failed: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":1062,"sourceCodeEnd":1098,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L1062-L1098","documentation":"deleteNodeTxn fails when a node ID in the requested batch does not exist in the 'nodes' table (txn.First returns nil). Deletion is aborted atomically so previously processed node deletions in the same txn are rolled back. Raised through StateStore.DeleteNode.","triggerScenarios":"Calling DeleteNode with a node ID that was already deregistered, never registered, or mistyped; also occurs when two concurrent deregistrations race and the second one targets the now-deleted node.","commonSituations":"Retry/duplicate delivery of a deregistration request; operators deleting nodes via API with stale IDs after garbage collection removed them; typo'd node UUID in a script.","solutions":["Verify the node ID exists via the node lookup API before calling DeleteNode.","Treat 'node not found' as an idempotent success in callers and skip it.","Filter the requested ID list to nodes that still exist to avoid aborting the whole batch.","Check for concurrent deregistration flows that may have already removed the node."],"exampleFix":"// before\nif err := store.DeleteNode(idx, nodeIDs); err != nil { return err }\n// after\nfor _, id := range nodeIDs {\n    if _, err := store.NodeByID(nil, id); err != nil || exists == nil {\n        continue // skip already-deleted nodes\n    }\n}\nerr := store.DeleteNode(idx, existingIDs)","handlingStrategy":"try-catch","validationCode":"for _, id := range nodeIDs {\n    n, err := store.NodeByID(nil, id)\n    if err != nil {\n        return err\n    }\n    if n == nil {\n        return fmt.Errorf(\"node %s does not exist\", id)\n    }\n}","typeGuard":"func nodeExists(s *state.StateStore, id string) bool {\n    n, err := s.NodeByID(nil, id)\n    return err == nil && n != nil\n}","tryCatchPattern":"if err := store.DeleteNode(idx, nodeIDs); err != nil {\n    if strings.HasPrefix(err.Error(), \"node not found:\") {\n        // idempotent success or skip missing node\n        return nil\n    }\n    return err\n}","preventionTips":["Look up nodes before deregistering and skip already-deleted IDs.","Design deregistration flows to be idempotent.","Serialize deregistration and drain operations to avoid delete/delete races.","Validate node UUIDs against the API before scripted deletions."],"tags":["nomad","state-store","node-deregistration","missing-entity"],"backgroundTag":"resource-not-found","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"}