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

object.FromEvent(): avoid database queries while holding mutex #266

Open
julianbrost opened this issue Jul 29, 2024 · 0 comments
Open

object.FromEvent(): avoid database queries while holding mutex #266

julianbrost opened this issue Jul 29, 2024 · 0 comments

Comments

@julianbrost
Copy link
Collaborator

Currently, object.FromEvent() performs some database interaction while holding a mutex:
https://github.com/Icinga/icinga-notifications/blob/8102c7797364a1f184526a19083220fa7d7a46c9/internal/object/object.go

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:

  1. 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 Fix broken runtime config sync icinga2#10013.
  2. While adding MySQL/MariaDB support, we noticed that the database queries currently performed are susceptible to InnoDB locking issues, see Port schema to MySQL 5.7 / MariaDB 10.2 #203 (review) and following comments. Currently, this happens to be prevented by the current locking, but if we improve this, this has to be addressed.
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

1 participant