{"record":{"id":"9251168f77b7a620","repo":"dgraph-io/dgraph","slug":"reuse-raftid-duplicate-raft-id-d-to-removed-memb","errorCode":null,"errorMessage":"REUSE_RAFTID: Duplicate Raft ID %d to removed member: %+v","messagePattern":"REUSE_RAFTID: Duplicate Raft ID (.+?) to removed member: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"dgraph/cmd/zero/zero.go","lineNumber":549,"sourceCode":"\t}\n\n\tif m.ClusterInfoOnly {\n\t\t// This request only wants to access the membership state, and nothing else. Most likely\n\t\t// from our clients.\n\t\tcs := &pb.ConnectionState{\n\t\t\tState:      ms,\n\t\t\tMaxPending: s.orc.MaxPending(),\n\t\t}\n\t\treturn cs, err\n\t}\n\tif m.Addr == \"\" {\n\t\treturn &emptyConnectionState, errors.Errorf(\"NO_ADDR: No address provided: %+v\", m)\n\t}\n\n\tfor _, member := range ms.Removed {\n\t\t// It is not recommended to reuse RAFT ids.\n\t\tif member.GroupId != 0 && m.Id == member.Id {\n\t\t\treturn &emptyConnectionState, errors.Errorf(\n\t\t\t\t\"REUSE_RAFTID: Duplicate Raft ID %d to removed member: %+v\", m.Id, member)\n\t\t}\n\t}\n\n\tnumberOfNodes := len(ms.Zeros)\n\tfor _, group := range ms.Groups {\n\t\tfor _, member := range group.Members {\n\t\t\tswitch {\n\t\t\tcase member.Addr == m.Addr && m.Id == 0:\n\t\t\t\tglog.Infof(\"Found a member with the same address. Returning: %+v\", member)\n\t\t\t\tconn.GetPools().Connect(m.Addr, s.tlsClientConfig)\n\t\t\t\treturn &pb.ConnectionState{\n\t\t\t\t\tState:  ms,\n\t\t\t\t\tMember: member,\n\t\t\t\t}, nil\n\n\t\t\tcase member.Addr == m.Addr && member.Id != m.Id:\n\t\t\t\t// Same address. Different Id. If Id is zero, then it might be trying to connect for","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/zero/zero.go#L531-L567","documentation":"Zero keeps a list of removed members precisely so their Raft IDs are never reused. If a node connects claiming an ID that matches an entry in membership state's Removed list (with a non-zero group), Zero rejects the connection: reusing a Raft ID corrupts consensus history. The node must be provisioned with a fresh ID or the stale removed entry cleared deliberately.","triggerScenarios":"Calling Connect with m.Id equal to the Id of a member in ms.Removed (member.GroupId != 0); typically re-adding a wiped alpha that kept its old Raft state/p_id, or misconfigured --raft \"id\" flag colliding with a removed node.","commonSituations":"Rebuilding a node from a snapshot that preserved the Raft ID; cloning a VM/container image with an existing p/raft state; restoring postings dir without clearing raft groups; CI reuse of fixed raft IDs.","solutions":["Delete the node's Raft/wal state (the p directory) so it starts with a brand-new Raft ID, then reconnect.","Provision the node with a unique, unused --raft \"id=<n>\" value.","If the removal was a mistake and the old node is truly gone, restart Zero cluster state or manually account for the removed member before reusing the ID.","Never clone data directories between nodes; ensure each node gets fresh Raft state."],"exampleFix":"// before (reused id from removed member)\ndgraph alpha --my=a1:7080 --zero=z1:5080 --raft \"id=2\"\n\n// after (fresh raft state)\nrm -rf p && dgraph alpha --my=a1:7080 --zero=z1:5080","handlingStrategy":"validation","validationCode":"state := fetchZeroState(\"http://zero:6080/state\")\nfor _, rm := range state.Removed {\n    if rm.Id == myRaftID {\n        return fmt.Errorf(\"raft id %d belongs to a removed member; wipe p/ or pick a new id\", myRaftID)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := zc.Connect(ctx, m)\nif err != nil && strings.Contains(err.Error(), \"REUSE_RAFTID\") {\n    return fmt.Errorf(\"never reuse a removed member's raft id; wipe raft state and rejoin: %w\", err)\n}","preventionTips":["Never clone nodes with existing p (raft) directories; provision fresh state per instance.","Check Zero /state Removed list before assigning static --raft ids.","Document that re-imaged nodes must start with clean raft state."],"tags":["dgraph-zero","raft","membership","cluster-management"],"backgroundTag":"raft-id-reuse","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}