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

Not able to maintain order of messages #6

Open
RonStein2000 opened this issue Jul 6, 2020 · 4 comments
Open

Not able to maintain order of messages #6

RonStein2000 opened this issue Jul 6, 2020 · 4 comments

Comments

@RonStein2000
Copy link

I created a pool actor (basic actor) which internally uses another N basic working actors which do the processing round-robin. After all items to process were sent to the pool, I sent an "end-of-work" marker for each working actor with the assumption that they are handled last (after the last item sent) by the actor. When the end marker was received, the actor would countdown a latch and I can then wait for the pool to be finished with all items when the latch is done for all actors. This did not work as expected - only if I add a delay after the item sending phase (~ 100ms) the "end-of-work" markers are in order. Without the delay, the end-markers got handled before some items and that of course crashed the semantics. Is this intended? What am I missing here?

@lihaoyi
Copy link
Member

lihaoyi commented Jul 6, 2020

You’ll need to provide a self contained code snippet demonstrating the issue, otherwise it is impossible to guess what you are soing wrong

@RonStein2000
Copy link
Author

RonStein2000 commented Jul 7, 2020

CodeSample.zip
There is a ref. to streamExecutionContext you must replace with a normal simple execution context. In the test I had to add the delay, otherwise it fails. I am using version 0.1.3 of castor. You may ignore the functionality related to the blocking queue, as it is not relevant for the test and my issue. Thanks in advance for any help or insight.

@lihaoyi
Copy link
Member

lihaoyi commented Jul 8, 2020

@RonStein2000 can you minimize the issue further? There's still too much code in there to dig through for me to be able to help

@RonStein2000
Copy link
Author

RonStein2000 commented Jul 8, 2020

I am sorry. Now here comes my next try (see attachment). I do not think I can minimize it further. You will need scala test to execute the test. I have used scala 2.12.11. If the delay (as in the code) is set to 0, the test will fail. If you set it to 20 millis, it will pass. The question is why? My assumption would be, that the end elements are processed last (in order) by each actor.
WorkActorPoolMinimizedTest.scala.zip

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

2 participants