quickfixgo / quickfix

The Go FIX Protocol Library :rocket:

Home Page:https://www.quickfixgo.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Concurrent map access panic in acceptor

smulube opened this issue · comments

Hello we are currently using QuickFIXGo in a UAT environment as an acceptor and we have been seeing intermittent panics related to concurrent map accesses within acceptor.go. Unfortunately I don't have a copy of the stack trace to hand but what I suspect is happening is related to concurrent modifications of the maps within the Acceptor struct (sessions which is a map[SessionID]*session and sessionAddr which is a map[SessionID]net.Addr).

Examples of the maps being read or modified inside a spawned goroutine I believe can be seen here: https://github.com/quickfixgo/quickfix/blob/master/acceptor.go#L291 or https://github.com/quickfixgo/quickfix/blob/master/acceptor.go#L307

We have created a fork of the library in which we've added a sync.RWMutex to Acceptor and we are now protecting any reads or modifications to either the sessions or sessionAddr maps, and since making this change we have not seen any repeat of the problem.

Would this change be useful to submit as a pull request, or is there some reason why those map modifications weren't already being guarded by a mutex that we are missing? It's possible that the fact that we haven't seen repeat occurrences is not related to our changes, but would be happy to send it over as a pull request if you think it would be useful.

thanks

thanks, yep we have a similar fix in our branch but would like to get this merged into the main line if possible so maybe I will open that PR to try and get that process started.

I have opened a PR to fix it and another issue.
#432