Skip to content

fix: Wrap disable_uptime_monitor in a transaction for broken_monitor task #91989

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajay-sentry
Copy link
Contributor

This PR aims to fix instances where the broken monitor checker would leave uptimes in an inconsistent / broken state and then prevent them from being fixed / run again.

Within disable_uptime_monitor we are setting the uptime status to be "OK" in the middle of the disable function

# We set the status back to ok here so that if we re-enable we'll start
# from a good state
uptime_subscription.update(uptime_status=UptimeStatus.OK)

The task relies on the UptimeSubscription have "failed" status here:

UptimeSubscription.objects.filter(
uptime_status=UptimeStatus.FAILED,
uptime_status_update_date__lt=timezone.now() - BROKEN_MONITOR_AGE_LIMIT,
)

If the disable job fails / exists early / etc. before actually running through everything, this would leave broken monitors in potentially a worse state than before. Looking at all the other usages of disable / enable_uptime_monitors, they seem to be wrapped in a transaction one level above the call site, so I did something similar here.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@ajay-sentry ajay-sentry requested a review from a team as a code owner May 20, 2025 22:44
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 20, 2025
Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

⚠️ Parser warning

The parser emitted a warning. Please review your JUnit XML file:

Warning while parsing testcase attributes: Limit of string is 1000 chars, for name, we got 2083 at 1:157341 in /home/runner/work/sentry/sentry/.artifacts/pytest.junit.xml
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #91989       +/-   ##
===========================================
+ Coverage   32.70%   86.49%   +53.79%     
===========================================
  Files        8743    10355     +1612     
  Lines      488141   587476    +99335     
  Branches    22588    22588               
===========================================
+ Hits       159628   508165   +348537     
+ Misses     328086    78884   -249202     
  Partials      427      427               

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant