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

[BUG] Message not delivered to Processor #173

Closed
troygilman0 opened this issue Dec 24, 2024 · 2 comments
Closed

[BUG] Message not delivered to Processor #173

troygilman0 opened this issue Dec 24, 2024 · 2 comments

Comments

@troygilman0
Copy link
Contributor

I have found a bug where some messages are not delivered to the Processor by the Inbox. This behavior can only be observed when processing many messages. The issue only happens under the given scenario:

  1. [goroutine 1] Inbox is running - inbox.run()
  2. [goroutine 1] Ring buffer is empty so the function returns - inbox.run()
  3. [goroutine 2] A message is added to the ring buffer - inbox.Send()
  4. [goroutine 2] The message is not scheduled because the procStatus is "running" - inbox.schedule()
  5. [goroutine 1] The procStatus is set to "idle" - inbox.process()

No further messages are sent to the inbox so the message from step 3 is never processed.

Example:

func TestSendMany(t *testing.T) {
	e, err := NewEngine(NewEngineConfig())
	require.NoError(t, err)
	for i := 0; i < 100000; i++ {
		done := make(chan struct{})
		e.SpawnFunc(func(ctx *Context) {
			switch ctx.Message().(type) {
			case Started:
				ctx.SpawnChildFunc(func(*Context) {}, "child")
				e.Stop(ctx.PID())
			case Stopped:
				// the child will receive a poisonPill when stopping
				// this will hang if the child's poisonPill is nnot processed
				close(done)
			}
		}, "test")
		timer := time.NewTimer(time.Second)
		select {
		case <-done:
			timer.Stop()
		case <-timer.C:
			t.Errorf("timed out")
			return
		}
	}
}
@anthdm
Copy link
Owner

anthdm commented Jan 3, 2025

@troygilman0 I'm working on verifying the bug right now. I'll keep you posted. Thanks for the work.

@anthdm
Copy link
Owner

anthdm commented Jan 3, 2025

Solved. Thanks @troygilman0

@anthdm anthdm closed this as completed Jan 3, 2025
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