You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Usiel (via GitHub)" <gi...@apache.org> on 2025/03/05 09:04:05 UTC
[PR] fix(beat): prune_query celery task args fix [superset]
Usiel opened a new pull request, #32511:
URL: https://github.com/apache/superset/pull/32511
### SUMMARY
The `prune_query` task fails because `prune_query.request.properties` has no entry for `retention_period_days` when using a RabbitMQ broker.
The task works fine when using sqlite as a broker. From what I could gather from celery's docs (e.g. https://docs.celeryq.dev/en/latest/userguide/periodic-tasks.html#available-fields) `args` or `kwargs` should be the preferred mechanism to pass args to a task. `options` is to be used to override `apply_async` args (e.g. `queue`, `priority`, ...). The fact that a sqlite broker passes any option to the task seems more like an oversight.
The change makes sure that people who have been happily using sqlite with the old beat schedule are not impacted (besides a new warning log).
```
superset-worker-dev-0 worker [2025-03-05 06:49:10,476: ERROR/MainProcess] Task prune_query[6f48cb1c-48fb-498a-8fca-f28f95ea296d] raised unexpected: TypeError('unsupported type for timedelta days component: NoneType')
superset-worker-dev-0 worker Traceback (most recent call last):
superset-worker-dev-0 worker File "/opt/.pyenv/versions/3.11.4/envs/superset/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
superset-worker-dev-0 worker R = retval = fun(*args, **kwargs)
superset-worker-dev-0 worker ^^^^^^^^^^^^^^^^^^^^
superset-worker-dev-0 worker File "/opt/.pyenv/versions/3.11.4/envs/superset/lib/python3.11/site-packages/superset/initialization/__init__.py", line 113, in __call__
superset-worker-dev-0 worker return task_base.__call__(self, *args, **kwargs)
superset-worker-dev-0 worker ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
superset-worker-dev-0 worker File "/opt/.pyenv/versions/3.11.4/envs/superset/lib/python3.11/site-packages/celery/app/trace.py", line 736, in __protected_call__
superset-worker-dev-0 worker return self.run(*args, **kwargs)
superset-worker-dev-0 worker ^^^^^^^^^^^^^^^^^^^^^^^^^
superset-worker-dev-0 worker File "/opt/.pyenv/versions/3.11.4/envs/superset/lib/python3.11/site-packages/superset/tasks/scheduler.py", line 134, in prune_query
superset-worker-dev-0 worker ).run()
superset-worker-dev-0 worker ^^^^^
superset-worker-dev-0 worker File "/opt/.pyenv/versions/3.11.4/envs/superset/lib/python3.11/site-packages/superset/commands/sql_lab/query.py", line 63, in run
superset-worker-dev-0 worker < datetime.now() - timedelta(days=self.retention_period_days)
superset-worker-dev-0 worker ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
superset-worker-dev-0 worker TypeError: unsupported type for timedelta days component: NoneType
```
### TESTING INSTRUCTIONS
#### RabbitMQ Test
Pre: Set up RabbitMQ (https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/rabbitmq.html#)
1. Configure Superset to use the RabbitMQ broker (`broker_url = "amqp://...`)
2. Uncomment the `prune_query` schedule
3. Set the schedule to run every minute
Expected: `prune_query` succeeds
#### Backwards Compatibility Test
1. Uncomment the `prune_query` schedule
2. Change `kwargs` to `options` to replicate the old schedule
3. Set the schedule to run every minute
Expected: `prune_query` succeeds but logs a warning
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
None of the above
--
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(beat): prune_query celery task args fix [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #32511:
URL: https://github.com/apache/superset/pull/32511#issuecomment-2700300511
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/32511?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `33.33333%` with `4 lines` in your changes missing coverage. Please review.
> Project coverage is 65.65%. Comparing base [(`76d897e`)](https://app.codecov.io/gh/apache/superset/commit/76d897eaa2f9e137102bc194c2e3109c29d0348f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`e5fe2cd`)](https://app.codecov.io/gh/apache/superset/commit/e5fe2cd6c7445ed41a68d6a24cef8e64d68be39d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 1533 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/32511?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/tasks/scheduler.py](https://app.codecov.io/gh/apache/superset/pull/32511?src=pr&el=tree&filepath=superset%2Ftasks%2Fscheduler.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdGFza3Mvc2NoZWR1bGVyLnB5) | 33.33% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/32511?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 #32511 +/- ##
==========================================
+ Coverage 60.48% 65.65% +5.16%
==========================================
Files 1931 547 -1384
Lines 76236 39252 -36984
Branches 8568 0 -8568
==========================================
- Hits 46114 25770 -20344
+ Misses 28017 13482 -14535
+ Partials 2105 0 -2105
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/32511/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/32511/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `48.49% <33.33%> (-0.67%)` | :arrow_down: |
| [javascript](https://app.codecov.io/gh/apache/superset/pull/32511/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/32511/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.00% <33.33%> (-0.80%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/32511/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `65.65% <33.33%> (+2.16%)` | :arrow_up: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/32511/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `61.20% <0.00%> (+3.58%)` | :arrow_up: |
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/32511?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).
--
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(beat): prune_query celery task args fix [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on code in PR #32511:
URL: https://github.com/apache/superset/pull/32511#discussion_r1981968119
##########
superset/tasks/scheduler.py:
##########
@@ -123,13 +124,20 @@ def prune_log() -> None:
@celery_app.task(name="prune_query")
-def prune_query() -> None:
+def prune_query(retention_period_days: Optional[int] = None) -> None:
stats_logger: BaseStatsLogger = app.config["STATS_LOGGER"]
stats_logger.incr("prune_query")
+ if retention_period_days is None:
+ retention_period_days = prune_query.request.properties.get(
+ "retention_period_days"
+ )
+ logger.warning(
+ "Your `prune_query` beat schedule uses `options` to pass the retention "
+ "period, please use `kwargs` instead."
+ )
Review Comment:
I think we should deprecate this and remove support for `options` based retention periods in 6.0. Can we add a comment along the lines of
```python
# TODO: Deprecated: Remove support for passing retention period via options in 6.0
```
--
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(beat): prune_query celery task args fix [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on PR #32511:
URL: https://github.com/apache/superset/pull/32511#issuecomment-2702729374
@Usiel here's the project card (it will be added for lazy consensus when we approach 6.0): https://github.com/orgs/apache/projects/462/views/1?pane=issue&itemId=100588266. Btw, it would be great to hear what your experiences with RabbitMQ have been, as I believe others may also be interested in trying it instead of Redis.
--
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(beat): prune_query celery task args fix [superset]
Posted by "Usiel (via GitHub)" <gi...@apache.org>.
Usiel commented on PR #32511:
URL: https://github.com/apache/superset/pull/32511#issuecomment-2702847792
RabbitMQ has been pretty much an off-hands experience for us. We use RabbitMQ for our Airflow deployments as well.
We did have issues sometimes when a downstream data source is acting out which eventually leads to a congestion (in conjunction with our high `SQLLAB_ASYNC_TIME_LIMIT_SEC`). I don't think this is specific to RabbitMQ though.
--
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(beat): prune_query celery task args fix [superset]
Posted by "Usiel (via GitHub)" <gi...@apache.org>.
Usiel commented on PR #32511:
URL: https://github.com/apache/superset/pull/32511#issuecomment-2702646632
Thanks for the review! I rebased and included the deprecation comment.
--
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(beat): prune_query celery task args fix [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro merged PR #32511:
URL: https://github.com/apache/superset/pull/32511
--
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(beat): prune_query celery task args fix [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #32511:
URL: https://github.com/apache/superset/pull/32511#discussion_r1980982612
##########
superset/tasks/scheduler.py:
##########
@@ -123,13 +124,20 @@ def prune_log() -> None:
@celery_app.task(name="prune_query")
-def prune_query() -> None:
+def prune_query(retention_period_days: Optional[int] = None) -> None:
Review Comment:
### Missing retention period validation <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The task accepts negative integers or zero as valid retention periods, which could lead to unintended data loss.
###### Why this matters
Without validation, negative or zero values could cause immediate deletion of all queries or other unexpected behavior.
###### Suggested change ∙ *Feature Preview*
Add validation for the retention period value. Example:
```python
@celery_app.task(name="prune_query")
def prune_query(retention_period_days: Optional[int] = None) -> None:
if retention_period_days is not None and retention_period_days <= 0:
raise ValueError("retention_period_days must be a positive integer")
```
</details>
<sub>
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d72d0e02-ad88-44ae-ba3b-dada3e5b52e8?suggestedFixEnabled=true)
💬 Chat with Korbit by mentioning @korbit-ai.
</sub>
<!--- korbi internal id:047a6d9a-816b-4214-9573-ae81043df7d8 -->
--
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(beat): prune_query celery task args fix [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on PR #32511:
URL: https://github.com/apache/superset/pull/32511#issuecomment-2702524218
FYI @Usiel there was an unrelated issue on master branch that caused the `pre-commit` checks to fail. if you rebase the PR the problem should go away.
--
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