JKOK005 / nus-monorepo

Repo for NUS courses code commits
1 stars 0 forks source link

Node registers is_local flag in nodeInfo struct as false #29

Closed JKOK005 closed 4 years ago

JKOK005 commented 4 years ago

is_local flag is set to false for the node itself. This messes up finger table routing.

Screen Shot 2019-11-14 at 4 04 49 PM

From screen shot, we note that the node is constantly requesting the data to be routed to itself since is_local flag is set to false. This triggers an infinite recursion loop which causes the program to crash eventually

JKOK005 commented 4 years ago

Also note an additional bug. Hash group number is wrongly set. The number should be 1 but it is declared as 0

JKOK005 commented 4 years ago

Resolving the issue with basehashgroup =0

Suspect that it is due to the following lines: func (f *FingerTable) findSuccessor(baseHashGroupsInt []uint32, value uint32, successors *[]util.NodeInfo) bool { /* Iterate through list of baseHashGroups Check if the correct hash is found and add to the successors */ for _, eInt := range baseHashGroupsInt { if eInt == value { nodePath, _ := zkCli.GetNodePaths(zkCli. PrependNodePath(fmt.Sprintf("%d", eInt))) nodeData, _ := zkCli.GetNodeValue(zkCli.PrependNodePath(fmt. Sprintf("%d/%s", eInt, nodePath[0]))) nodeInfo := new(util.NodeInfo) json.Unmarshal(nodeData, nodeInfo) nodeInfo.IsLocal = false *successors = append(*successors, *nodeInfo) return true } } return false }

Line 52 in Fingertable.go

JKOK005 commented 4 years ago

When you create a new nodeinfo, you only unmarshall the information registered in ZooKeeper. The information registered are only the node's address and port.

As such, the basehashgroup value gets initialised with a 0 value by default in the call to nodeInfo := new(util.NodeInfo)

stefelmanns commented 4 years ago

Fixed with branch, has been merged.