Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic on remove #3

Open
akram opened this issue Dec 6, 2023 · 0 comments
Open

panic on remove #3

akram opened this issue Dec 6, 2023 · 0 comments

Comments

@akram
Copy link

akram commented Dec 6, 2023

func main() {
	nodes := []string{"shard-1", "shard-2", "shard-3"}
	config := &xring.Config{
		VirtualNodes: len(nodes),
		LoadFactor:   40,
	}
	hashRing := xring.NewRing(nodes, config)
	keyCount := 100

	fmt.Println("with 3 nodes")
	distribution := simulateKeyDistribution(hashRing, keyCount)
	printDistribution(distribution)

	fmt.Println("------------------------------------------------")
	fmt.Println("with 4 nodes")
	hashRing.Add("shard-4")
	distribution = simulateKeyDistribution(hashRing, keyCount)
	printDistribution(distribution)

	fmt.Println("------------------------------------------------")
	fmt.Println("with 5 nodes")
	hashRing.Add("shard-5")
	distribution = simulateKeyDistribution(hashRing, keyCount)
	printDistribution(distribution)

	fmt.Println("------------------------------------------------")
	fmt.Println("with 4 nodes")
	hashRing.Remove("shard-4")
	distribution = simulateKeyDistribution(hashRing, keyCount)
	printDistribution(distribution)

}

and then I got:

------------------------------------------------
with 4 nodes
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104afbbd8]

goroutine 1 [running]:
github.com/arriqaaq/rbt.(*Tree).delete(0x140000a13e0?, 0x140000aa4e0?)
	/Users/akram/go/pkg/mod/github.com/arriqaaq/[email protected]/rbt.go:265 +0x1e8
github.com/arriqaaq/rbt.(*Tree).Delete(0x104afe391?, 0x140000a13e0?)
	/Users/akram/go/pkg/mod/github.com/arriqaaq/[email protected]/rbt.go:242 +0x2c
github.com/argoproj/xring.(*Ring).Remove(0x140000b8000, {0x104afe5d0, 0x7})
	/Users/akram/go/src/github.com/arriqaaq/xring/xring.go:144 +0x244
main.main()
	/Users/akram/go/src/github.com/arriqaaq/xring/examples/relocation.go:82 +0x2a0
exit status 2
@akram akram changed the title fatal error on remove panic on remove Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant