You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2026/04/22 01:21:41 UTC

[PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

eschutho opened a new pull request, #39533:
URL: https://github.com/apache/superset/pull/39533

   ### SUMMARY
   
   Fixes a bug where alert/report schedules get permanently stuck in `WORKING` state when a Celery worker pod crashes mid-execution (SC-104379).
   
   **Root cause:** When a pod crashes, the report stays in `WORKING` state. On broker requeue (after Redis `visibility_timeout`, ~30 min at Preset), the new worker enters `ReportWorkingState.next()` and raises `ReportSchedulePreviousWorkingError` — blocking re-execution for up to 1 hour until `working_timeout` expires, at which point it transitions to `ERROR` rather than retrying.
   
   **Fix:** Adds a three-branch state machine in `ReportWorkingState.next()`:
   1. `elapsed >= working_timeout` → ERROR (existing behavior — genuinely runaway job)
   2. `elapsed >= ALERT_REPORTS_STALE_WORKING_TIMEOUT` (new config, default 300s) → reset to NOOP and re-execute via `ReportNotTriggeredErrorState`
   3. `elapsed < stale threshold` → `PreviousWorkingError` (existing behavior — might be legitimately running)
   
   Also refactors `is_on_working_timeout()` to accept an already-fetched log, eliminating a redundant DB query on every working-state evaluation.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — backend-only change.
   
   ### TESTING INSTRUCTIONS
   
   1. Unit tests cover all three branches — run `pytest tests/unit_tests/commands/report/execute_test.py`
   2. To manually verify: create an alert/report, start a Celery worker, kill the worker mid-execution (while report is in `WORKING` state), restart the worker, confirm the report re-executes rather than staying stuck until `working_timeout` expires.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   New config key: `ALERT_REPORTS_STALE_WORKING_TIMEOUT` (seconds, default 300). Must be less than `working_timeout` on any schedule.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho closed pull request #39533: fix(alerts): recover reports stuck in WORKING state after worker crash
URL: https://github.com/apache/superset/pull/39533


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39533:
URL: https://github.com/apache/superset/pull/39533#issuecomment-4292908349

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #39533:
URL: https://github.com/apache/superset/pull/39533#issuecomment-5040335288

   This one looks solid and worth landing, just conflicting with master now. Mind rebasing when you get a chance? The one CI failure looks like the flaky cypress job. Happy to help if you'd like.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39533:
URL: https://github.com/apache/superset/pull/39533#issuecomment-4293013259

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39533?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `40.00000%` with `9 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 64.54%. Comparing base ([`05fc5bb`](https://app.codecov.io/gh/apache/superset/commit/05fc5bb424f000e072b76c35ab465416c8a38f1f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`3fe7b64`](https://app.codecov.io/gh/apache/superset/commit/3fe7b64f696c0247c9069ee33ec4480c4d02304b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/39533?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/commands/report/execute.py](https://app.codecov.io/gh/apache/superset/pull/39533?src=pr&el=tree&filepath=superset%2Fcommands%2Freport%2Fexecute.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvcmVwb3J0L2V4ZWN1dGUucHk=) | 35.71% | [7 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/39533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #39533      +/-   ##
   ==========================================
   - Coverage   64.54%   64.54%   -0.01%     
   ==========================================
     Files        2559     2561       +2     
     Lines      133496   133480      -16     
     Branches    31028    31018      -10     
   ==========================================
   - Hits        86168    86156      -12     
   + Misses      45836    45827       -9     
   - Partials     1492     1497       +5     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.86% <13.33%> (+0.03%)` | :arrow_up: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.51% <40.00%> (+0.04%)` | :arrow_up: |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.64% <13.33%> (+0.03%)` | :arrow_up: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `62.04% <40.00%> (-0.01%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.14% <40.00%> (+0.04%)` | :arrow_up: |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/39533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/39533?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39533:
URL: https://github.com/apache/superset/pull/39533#issuecomment-4292912566

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | c7f053f6488bcbe30196bf08dfb0bed538093f89 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e822a5a47b0e0008d8b536 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39533--superset-docs-preview.netlify.app](https://deploy-preview-39533--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM5NTMzLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.JSyVtFlaiBjMAnqp9FlWZcMi5zWZu1TXq7n9QNBfBKk)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-39533--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #39533:
URL: https://github.com/apache/superset/pull/39533#discussion_r3121124678


##########
superset/config.py:
##########
@@ -1971,6 +1971,10 @@ def EMAIL_HEADER_MUTATOR(  # pylint: disable=invalid-name,unused-argument  # noq
 ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT = 3600
 ALERT_REPORTS_DEFAULT_RETENTION = 90
 ALERT_REPORTS_DEFAULT_CRON_VALUE = "0 0 * * *"  # every day
+# Minimum elapsed time (seconds) before a WORKING state is considered stale
+# (e.g. due to a crashed Celery worker) and eligible for reset + retry.
+# Must be less than working_timeout on any schedule.

Review Comment:
   ```suggestion
   # It would ideally be less than working_timeout on any schedule.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(alerts): recover reports stuck in WORKING state after worker crash [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #39533:
URL: https://github.com/apache/superset/pull/39533#issuecomment-5546404028

   Heya @eschutho, checking back in, this one's still worth landing. Just needs a rebase and that flaky cypress job cleared. Say the word if you want a hand with some commits/CI-wrangling.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org