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

DEV-46209 - Fix evaluation headers concurrency issue #37

Merged

Conversation

yasmin-tr
Copy link

@yasmin-tr yasmin-tr commented Aug 14, 2024

What is this feature?
This is a fix to bug introduced on the code adding logzio headers to the alert evaluation.
We got the exception of: fatal error: concurrent map iteration and map write that was crashing the service.
This happened more often the more alert rules were evaluated at the same time, and the exception was originating at the following place in eval.go : 321
image

The error means that the map object (the headers) had access and write operations at the same time.

Root Cause
The root cause for this is that the headers were added from the api request context and since the evaluate API is done in bulk for multiple alert rules at the same time, they were sharing the same headers object - which is passed as reference into the evaluation.
image
image

What Was the Fix?
To fix the concurrency issue of accessing the same object we needed to clone it.
So instead of passing same headers reference we just cloned it to be a separate reference for each alert evaluation that is sent.
image

** Also added the following changes:**

  • small refactor on how headers are built based on similar existing code
  • added / changed logs to contain rule and org information for easier investigations
  • removed in eval.go some redundant logz changes (reverted to original code)

Why do we need this feature?
The obvious reason - server should not crash because of error when running multiple alert evaluations.
We need to support big scale and evaluation of a lot of alerts a the same time.

also added the following changes:
* small refactor on how headers are built based on similar existing code
* added / changed logs to contain rule and org information for easier investigations
* removed in eval.go some redundant logz changed (reverted to original code)
@yasmin-tr
Copy link
Author

run-test

@yasmin-tr yasmin-tr requested a review from ohadza August 14, 2024 09:30
@yasmin-tr yasmin-tr self-assigned this Aug 15, 2024
@yasmin-tr yasmin-tr merged commit 73b2d9e into v10.4.x-logzio Aug 20, 2024
16 of 18 checks passed
@yasmin-tr yasmin-tr deleted the DEV-46209-fix-evaluation-headers-concurrency-issue branch August 20, 2024 11:53
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

Successfully merging this pull request may close these issues.

2 participants