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

Possible concurrency issue - events not being executed sequentially. #13

Closed
csiwek opened this issue Oct 28, 2016 · 6 comments
Closed

Comments

@csiwek
Copy link

csiwek commented Oct 28, 2016

Hi Dan,
This is the part which I'm going to challenge :-)

for _, handlerFunc := range self.eventHandlers[handleName] { go handlerFunc(event, self.connId) }

We've just had an issue when events are not being processed sequentially.
I's probably regarding to every handlerFunc being executed as a separate goroutine. From the library point of view, it makes perfectly sense. You can't block here - you want to process next event as soon as possible. Things get complicated when you need different time period to process events.
In out case we have spotted that library executes conference:del-member was fired before add-member.
When you want to build some kind of state machine it gets very messy.
What we did, we removed 'go' from the library but we are executing code as goroutine inside the handler function. If we require some events to be processed sequentially we can still do it.

What do you think? Did you have this issue in cgrates? can you afford to call every handler as goroutine?

greetings from Nexmo :-)
Cezary

@danbogos
Copy link
Collaborator

hey @csiwek

Good to hear from you (in one way happy you have issues ;) ).

Will make the possibility to have it synchronous there and close this issue when done.

DanB

@csiwek
Copy link
Author

csiwek commented Oct 30, 2016

thanks Dan,
I'm looking forward for your patch...
I was just wondering if you have experienced similar issue...?

@danbogos
Copy link
Collaborator

@csiwek, yes it did happened to us as well (eg: HANGUP before CHANNEL_CREATE) but we did not bother blocking there since I am not 100% FS sends them in order (although there are chances it does).

DanB

@danbogos
Copy link
Collaborator

danbogos commented Jul 2, 2017

hi @csiwek

Looking at the issues, I see this one still being opened. Did u work-around it? As said I cannot testify that FS sends events in order.

DanB

@csiwek
Copy link
Author

csiwek commented Jul 3, 2017

Hi @danbogos

For now, we have ended up by not executing the handlerFunc as a new goroutine (which I mentioned in the first post) and doing it when necessary inside those functions . This definitely fixes issues we were having so I guess FS is trying to keep events in the right order. I understand you probably will never experience this issue because the way you are using FS. Our application behaviour highly relies on the actual call state

@danbogos
Copy link
Collaborator

danbogos commented Jul 3, 2017

Thanks for the update. Please reopen if you think changes are needed.

Have a good one and see you most probably at ClueCon!

DanB

@danbogos danbogos closed this as completed Jul 3, 2017
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