Skip to content

router.NewConsistentHashPool has error occurred while closing #1142

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

Open
remainbeen opened this issue Apr 8, 2025 · 1 comment
Open

router.NewConsistentHashPool has error occurred while closing #1142

remainbeen opened this issue Apr 8, 2025 · 1 comment

Comments

@remainbeen
Copy link

remainbeen commented Apr 8, 2025

Describe the bug
I used router.NewConsistentHashPool to create a pool in cluster. Then when I closed the program, I got an error:
`7:46PM INF [ACTOR] Recovering lib=Proto.Actor system=fBr5nhw5vuR79aeLVBJe3V self="Address:"127.0.0.1:64236" Id:"partition-activator"" reason="runtime error: invalid memory address or nil pointer dereference"
debug.Stack(): goroutine 27 [running]:
runtime/debug.Stack()
C:/Program Files/Go/src/runtime/debug/stack.go:26 +0x5e
github.com/asynkron/protoactor-go/actor.(*actorContext).EscalateFailure(0xc000200900, {0x11ada40, 0x18d9d60}, {0x1236760, 0xc0006b2500})
D:/Study/protoactor-go/actor/actor_context.go:709 +0x19b
github.com/asynkron/protoactor-go/actor.(*defaultMailbox).run.func1()
D:/Study/protoactor-go/actor/mailbox.go:132 +0x58
panic({0x11ada40?, 0x18d9d60?})
C:/Program Files/Go/src/runtime/panic.go:785 +0x132
github.com/asynkron/protoactor-go/cluster/identitylookup/disthash.(*placementActor).onTerminated(0xc0002082d0, 0xc0006b2500)
D:/Study/protoactor-go/cluster/identitylookup/disthash/placement_actor.go:51 +0xe0
github.com/asynkron/protoactor-go/cluster/identitylookup/disthash.(*placementActor).Receive(0xc0002082d0, {0x13c86a8, 0xc000200900})
D:/Study/protoactor-go/cluster/identitylookup/disthash/placement_actor.go:39 +0x1fe
github.com/asynkron/protoactor-go/actor.(*actorContext).defaultReceive(0xc000200900)
D:/Study/protoactor-go/actor/actor_context.go:372 +0x98
github.com/asynkron/protoactor-go/actor.(*actorContext).processMessage(0xc000200900, {0x1236760, 0xc0006b2500})
D:/Study/protoactor-go/actor/actor_context.go:527 +0xf9
github.com/asynkron/protoactor-go/actor.(*actorContext).InvokeUserMessage(0xc000200900, {0x1236760, 0xc0006b2500})
D:/Study/protoactor-go/actor/actor_context.go:505 +0x465
github.com/asynkron/protoactor-go/actor.(*actorContext).handleTerminated(0xc000200900, 0xc0006b2500?)
D:/Study/protoactor-go/actor/actor_context.go:628 +0x49
github.com/asynkron/protoactor-go/actor.(*actorContext).InvokeSystemMessage(0xc000200900?, {0x1236760?, 0xc0006b2500?})
D:/Study/protoactor-go/actor/actor_context.go:561 +0x15e
github.com/asynkron/protoactor-go/actor.(*defaultMailbox).run(0xc000200960)
D:/Study/protoactor-go/actor/mailbox.go:154 +0x1a6
github.com/asynkron/protoactor-go/actor.(*defaultMailbox).processMessages(0xc000200960)
D:/Study/protoactor-go/actor/mailbox.go:105 +0x25
created by github.com/asynkron/protoactor-go/actor.goroutineDispatcher.Schedule in goroutine 1
D:/Study/protoactor-go/actor/dispatcher.go:13 +0x16

[Supervision] Actor: Address:"127.0.0.1:64236" Id:"partition-activator" failed with message: who:{Address:"127.0.0.1:64236" Id:"partition-activator/test$d/router"} exception: runtime error: invalid memory address or nil pointer dereference`

To Reproduce
The test code is in the attachment。
1 build and run it.
2 press CTRL+C to close it.
You will see the error ocurred。

main.go.txt

@remainbeen
Copy link
Author

I found the error occurred here:

`func (p *placementActor) onTerminated(msg *actor.Terminated) {
found, key, meta := p.pidToMeta(msg.Who)
clusterKind := p.cluster.GetClusterKind(meta.ID.Kind)
clusterKind.Dec()

activationTerminated := &clustering.ActivationTerminated{
	Pid:             msg.Who,
	ClusterIdentity: meta.ID,
}
p.partitionManager.cluster.MemberList.BroadcastEvent(activationTerminated, true)

if found {
	delete(p.actors, *key)
}

}`

The reason for the error is that the pool's pid is not registered in p.actors, so pidToMeta returns false and nil. No judgment is made here, which is incorrect behavior.

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