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

fix(notifier): fix fetching notifications by batch #974

Merged
merged 7 commits into from
Feb 7, 2024

Conversation

almostinf
Copy link
Member

@almostinf almostinf commented Dec 15, 2023

Fix fetching notifications by batch

The mechanism for reading the batched notification was broken in this PR to avoid making it unnecessarily large, the current PR solves this problem

To solve the problem we resave notifications on Maintenance with timestamp now() + resave_time, thus removing the traffic jam from the notification queue in the form of constantly hitting notifications on Maintenance in the batches

In addition, PR solves the problem with constant checking of notifications on Maintenance, now all checks will be done via resave_time

Carefully select the value of the resave_time variable! You don't want to make it too large, as this will affect the delay in sending notifications on Maintenance

@almostinf almostinf requested a review from a team as a code owner December 15, 2023 10:01
@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2023

Codecov Report

Attention: 115 lines in your changes are missing coverage. Please review.

Comparison is base (ad9cd9b) 68.19% compared to head (0d57c50) 68.12%.
Report is 7 commits behind head on master.

❗ Current head 0d57c50 differs from pull request most recent head 210db54. Consider uploading reports for the commit 210db54 to get more accurate results

Files Patch % Lines
database/redis/notification.go 72.36% 13 Missing and 8 partials ⚠️
cmd/cli/main.go 0.00% 19 Missing ⚠️
database/redis/metric.go 53.84% 5 Missing and 1 partial ⚠️
database/redis/reply/event.go 0.00% 4 Missing ⚠️
database/redis/reply/search_result.go 0.00% 4 Missing ⚠️
api/controller/team.go 78.57% 1 Missing and 2 partials ⚠️
api/handler/config.go 25.00% 2 Missing and 1 partial ⚠️
database/redis/reply/contact.go 0.00% 3 Missing ⚠️
database/redis/tag.go 0.00% 2 Missing and 1 partial ⚠️
database/redis/trigger.go 70.00% 1 Missing and 2 partials ⚠️
... and 33 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #974      +/-   ##
==========================================
- Coverage   68.19%   68.12%   -0.07%     
==========================================
  Files         208      208              
  Lines       11734    11785      +51     
==========================================
+ Hits         8002     8029      +27     
- Misses       3254     3272      +18     
- Partials      478      484       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -517,4 +528,22 @@ func (connector *DbConnector) AddNotifications(notifications []*moira.ScheduledN
return nil
}

func (connector *DbConnector) saveNotifications(ctx context.Context, pipe redis.Pipeliner, notifications []*moira.ScheduledNotification) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

есть функция AddNotifications она же такая же...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, AddNotifications добавляет уведомления под одинаковым таймстемпом, а saveNotifications просто сохраняет переданные, ожидая, что все нужные поля заполнены

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я думаю, что мы через пол года уже забудем в чем их отличие, а сходу не будучи в контексте ответить на это, кажется, мы сейчас не умеем :(

давайте завтра обговорим это место :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

заменил saveNotifications на resaveNotifications, у которого другая логика

@moira-alert moira-alert deleted a comment from Abobus1k Jan 15, 2024
Tetrergeru
Tetrergeru previously approved these changes Jan 22, 2024
@almostinf
Copy link
Member Author

/build

@almostinf almostinf merged commit ccb20ab into master Feb 7, 2024
6 checks passed
@almostinf almostinf deleted the fix/fix-fetching-notifications-with-batching branch February 7, 2024 09:03
Copy link

github-actions bot commented Feb 7, 2024

Build and push Docker images with tag: 2024-02-07.ccb20ab

1 similar comment
Copy link

github-actions bot commented Feb 7, 2024

Build and push Docker images with tag: 2024-02-07.ccb20ab

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.

4 participants