You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2026/07/15 14:05:03 UTC

(superset) branch master updated: fix(async-queries): add Celery task expiry to GAQ async query tasks (#42084)

This is an automated email from the ASF dual-hosted git repository.

dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 2af66b2c9b5 fix(async-queries): add Celery task expiry to GAQ async query tasks (#42084)
2af66b2c9b5 is described below

commit 2af66b2c9b541ffa1552029b94840c7072628a0c
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Wed Jul 15 15:04:56 2026 +0100

    fix(async-queries): add Celery task expiry to GAQ async query tasks (#42084)
    
    Co-authored-by: Claude Opus 4.6 (1M context) <no...@anthropic.com>
---
 superset/async_events/async_query_manager.py       | 30 ++++----
 .../async_events/async_query_manager_tests.py      | 83 ++++++++++++----------
 2 files changed, 63 insertions(+), 50 deletions(-)

diff --git a/superset/async_events/async_query_manager.py b/superset/async_events/async_query_manager.py
index 4a8c840e413..7cfbd6892df 100644
--- a/superset/async_events/async_query_manager.py
+++ b/superset/async_events/async_query_manager.py
@@ -293,13 +293,16 @@ class AsyncQueryManager:
         from superset import security_manager
 
         job_metadata = self.init_job(channel_id, user_id)
-        self._load_explore_json_into_cache_job.delay(
-            {**job_metadata, "guest_token": guest_user.guest_token}
-            if (guest_user := security_manager.get_current_guest_user_if_guest())
-            else job_metadata,
-            form_data,
-            response_type,
-            force,
+        self._load_explore_json_into_cache_job.apply_async(
+            args=[
+                {**job_metadata, "guest_token": guest_user.guest_token}
+                if (guest_user := security_manager.get_current_guest_user_if_guest())
+                else job_metadata,
+                form_data,
+                response_type,
+                force,
+            ],
+            expires=self._jwt_expiration_seconds,
         )
         return job_metadata
 
@@ -317,11 +320,14 @@ class AsyncQueryManager:
         # this way we can keep the cache key consistent between sync and async command
         # so that it can be looked up consistently
         job_metadata = self.init_job(channel_id, user_id)
-        self._load_chart_data_into_cache_job.delay(
-            {**job_metadata, "guest_token": guest_user.guest_token}
-            if (guest_user := security_manager.get_current_guest_user_if_guest())
-            else job_metadata,
-            form_data,
+        self._load_chart_data_into_cache_job.apply_async(
+            args=[
+                {**job_metadata, "guest_token": guest_user.guest_token}
+                if (guest_user := security_manager.get_current_guest_user_if_guest())
+                else job_metadata,
+                form_data,
+            ],
+            expires=self._jwt_expiration_seconds,
         )
         return job_metadata
 
diff --git a/tests/unit_tests/async_events/async_query_manager_tests.py b/tests/unit_tests/async_events/async_query_manager_tests.py
index 534d402e48a..421f4159fbb 100644
--- a/tests/unit_tests/async_events/async_query_manager_tests.py
+++ b/tests/unit_tests/async_events/async_query_manager_tests.py
@@ -41,6 +41,7 @@ def async_query_manager():
     query_manager = AsyncQueryManager()
     query_manager._jwt_secret = JWT_TOKEN_SECRET
     query_manager._jwt_cookie_name = JWT_TOKEN_COOKIE_NAME
+    query_manager._jwt_expiration_seconds = 3600
     return query_manager
 
 
@@ -246,25 +247,28 @@ def test_submit_chart_data_job_as_guest_user(
         form_data={},
     )
 
-    job_mock.delay.assert_called_once_with(
-        {
-            "channel_id": "test_channel_id",
-            "errors": [],
-            "guest_token": {
-                "user": {},
-                "resources": [{"type": "dashboard", "id": "some-uuid"}],
-                "rls_rules": [{"clause": '"STATEID" = 3'}],
-                "iat": 1700000000.0,
-                "exp": 1700000300.0,
-                "aud": "http://0.0.0.0:8080/",
-                "type": "guest",
+    job_mock.apply_async.assert_called_once_with(
+        args=[
+            {
+                "channel_id": "test_channel_id",
+                "errors": [],
+                "guest_token": {
+                    "user": {},
+                    "resources": [{"type": "dashboard", "id": "some-uuid"}],
+                    "rls_rules": [{"clause": '"STATEID" = 3'}],
+                    "iat": 1700000000.0,
+                    "exp": 1700000300.0,
+                    "aud": "http://0.0.0.0:8080/",
+                    "type": "guest",
+                },
+                "job_id": ANY,
+                "result_url": None,
+                "status": "pending",
+                "user_id": None,
             },
-            "job_id": ANY,
-            "result_url": None,
-            "status": "pending",
-            "user_id": None,
-        },
-        {},
+            {},
+        ],
+        expires=3600,
     )
 
     assert "guest_token" not in job_meta
@@ -349,27 +353,30 @@ def test_submit_explore_json_job_as_guest_user(
         response_type="json",
     )
 
-    job_mock.delay.assert_called_once_with(
-        {
-            "channel_id": "test_channel_id",
-            "errors": [],
-            "guest_token": {
-                "user": {},
-                "resources": [{"type": "dashboard", "id": "some-uuid"}],
-                "rls_rules": [{"clause": '"STATEID" = 3'}],
-                "iat": 1700000000.0,
-                "exp": 1700000300.0,
-                "aud": "http://0.0.0.0:8080/",
-                "type": "guest",
+    job_mock.apply_async.assert_called_once_with(
+        args=[
+            {
+                "channel_id": "test_channel_id",
+                "errors": [],
+                "guest_token": {
+                    "user": {},
+                    "resources": [{"type": "dashboard", "id": "some-uuid"}],
+                    "rls_rules": [{"clause": '"STATEID" = 3'}],
+                    "iat": 1700000000.0,
+                    "exp": 1700000300.0,
+                    "aud": "http://0.0.0.0:8080/",
+                    "type": "guest",
+                },
+                "job_id": ANY,
+                "result_url": None,
+                "status": "pending",
+                "user_id": None,
             },
-            "job_id": ANY,
-            "result_url": None,
-            "status": "pending",
-            "user_id": None,
-        },
-        {},
-        "json",
-        False,
+            {},
+            "json",
+            False,
+        ],
+        expires=3600,
     )
 
     assert "guest_token" not in job_meta