Skip to content

Conversation

@diegovb-sys
Copy link
Contributor

Closes #5354

📑 Description

In order to face the race condition. it has been modified the checking strategy after if the value is present.
With the current strategy, a query is built where we include the action in case of conflict, i.e when the lastalert already exists.
Moreover, as this strategy depends on the underlying engine, it has been implemented for 3 engines:

  • SQLite
  • PostreSQL
  • MySQL

About the fails catching, it has been moved to the decorator.

With this modification race conditions should be avoided, when the same alert (tenant+fingerprint) comes in twice.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

Since the function modified is so called in the principal flow, be careful in its review.

@vercel
Copy link

vercel bot commented Oct 14, 2025

@diegovb-sys is attempting to deploy a commit to the KeepHQ Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Bug Something isn't working labels Oct 14, 2025
@shahargl
Copy link
Member

@diegovb-sys it looks like linter fails, wdyt can you fix it?

@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

❌ Patch coverage is 23.07692% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.62%. Comparing base (97c263a) to head (eaf6d33).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
keep/api/core/db_utils.py 26.31% 14 Missing ⚠️
keep/api/core/db.py 14.28% 6 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (97c263a) and HEAD (eaf6d33). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (97c263a) HEAD (eaf6d33)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5364       +/-   ##
===========================================
- Coverage   46.39%   30.62%   -15.78%     
===========================================
  Files         176      101       -75     
  Lines       18412    11656     -6756     
===========================================
- Hits         8543     3570     -4973     
+ Misses       9869     8086     -1783     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Race condition in set_last_alert

2 participants