Fix Go routine race condition in DB notification map 15/4815/3 cherry v0.5.4
authorTimo Tietavainen <timo.tietavainen@nokia.com>
Wed, 7 Oct 2020 04:07:24 +0000 (07:07 +0300)
committerTimo Tietavainen <timo.tietavainen@nokia.com>
Wed, 7 Oct 2020 17:15:48 +0000 (20:15 +0300)
commit33961a269bf51f6c713fcb00576cdc0b9ac98ee9
tree1d676ded3e22cac188c9b298d38b7924d0ac2786
parent0f37fbdad6df038d57aaceb9313894995a7bc3cf
Fix Go routine race condition in DB notification map

Map cbMap was accessible by the main Go routine and also by a Go routine, which
handled incoming notifications from database (Redis). Problem was visible, when
unit tests were run with '-race' flag. Fix the issue by adding a mutex lock to
guard cbMap accesses. Go routine what handles incoming notification has a local
lockless copy of the cbMap to make sure that notification handling speed won't
be suffering from mutex locks. Local copy of cbMap is updated whenever the
cbMap has been updated.

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I066ff1d71340db2240a7ea6aeeb575f098488608
docs/release-notes.rst
internal/sdlgoredis/sdlgoredis.go
internal/sdlgoredis/sdlgoredis_test.go
sdl.go