Skip to content

Commit

Permalink
[FAB-10924] data race during event handler cleanup
Browse files Browse the repository at this point in the history
When sending a message to a handler fails due to session timeout or some
other transient failure, the channel range loop in the start method will
cleanup the handler from the event processor.

When the event server stream associated with a handler encounters an
error, the server will cleanup the handler from the event processor.

When the two things happen concurrently, two go routines will
concurrently execute cleanup. This results in a concurrent map
modification on the handler's interestedEvents map.

In context, it doesn't appear that the map removal is needed as the
handler's interests are being purged. Removing this processing resolves
the race.

Change-Id: I2383482c25a08dfa3045d696b7c20551fd9bc8ba
Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
sykesm committed Jul 2, 2018
1 parent 19883c4 commit f48cf5c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions events/producer/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,11 @@ func (ep *eventProcessor) deregisterHandler(ie *pb.Interest, h *handler) error {
}

func (ep *eventProcessor) deregisterAll(h *handler) {
for k, v := range h.interestedEvents {
for _, v := range h.interestedEvents {
if err := ep.deregisterHandler(v, h); err != nil {
logger.Errorf("failed deregistering event type %s for %s", v, h.RemoteAddr)
continue
}
delete(h.interestedEvents, k)
}
}

Expand Down

0 comments on commit f48cf5c

Please sign in to comment.