Closed mattiamanzati closed 11 months ago
I don't think that is the case. When an entity is terminated with termination message, we run:
queue.offer(msg).exit.as(map.updated(entityId, (None, interruptionFiber)))
Which means we enqueue the termination message, then we update the entity map with None
instead of the queue. As long as the value is None
, we're not creating a new queue:
case Some((None, _)) =>
// the queue is shutting down, stash and retry
ZIO.succeed((p, map))
So we are indeed waiting for the entity to terminate.
Yeah can confirm it achieved the same result by fixing the wait for shutdown of already terminating entities. Thanks a lot!
It seems like terminateEntity after sending the termination message to the queue does not wait for the created promise. That means that after the message is succefully delivered, the entity terminates immediatly without waiting for proper interruption.
Example written in typescript: https://github.com/mattiamanzati/shardcake/blob/dca200d6c6c3d10a18379355cc23c74fab6338cf/test/SampleTests.ts#L238-L290
Shard termination is handled fine instead, as all promises are awaited or timed out.