This obviously prevents part of the event processing from happening in parallel. It would of course be nicer if that wasn't the case.
There are two parts to this:
The mutex currently implicitly prevents two goroutines from interfering with each other when fetching/updating the same object. To address this, some kind of more sophisticated locking mechanism would be necessary, i.e. one that takes the object ID into account and only prevents concurrent calls for the same object, maybe something similar to ObjectNameLock from https://github.com/Icinga/icinga2/pull/10013.
While adding MySQL/MariaDB support, we noticed that the database queries currently performed are susceptible to InnoDB locking issues, see https://github.com/Icinga/icinga-notifications/pull/203#pullrequestreview-2180268854 and following comments. Currently, this happens to be prevented by the current locking, but if we improve this, this has to be addressed.
Currently,
object.FromEvent()
performs some database interaction while holding a mutex: https://github.com/Icinga/icinga-notifications/blob/8102c7797364a1f184526a19083220fa7d7a46c9/internal/object/object.goThis obviously prevents part of the event processing from happening in parallel. It would of course be nicer if that wasn't the case.
There are two parts to this:
ObjectNameLock
from https://github.com/Icinga/icinga2/pull/10013.