Repository navigation
fix(gtf): stop async poll when idle + back off; second-granularity durations - #43486
Conversation
…rations Task-list/polling polish surfaced while testing on Postgres: - Stop the chart-data status poll entirely once every awaited task settles (no perpetual idle heartbeat), and restart it — eager again — when a new waiter registers. - Exponential backoff: the poll starts at the eager interval, doubles (capped at 8× the base) while awaited tasks are quiet, and snaps back to eager the moment an awaited task changes or a new waiter registers. Keeps a long-running task responsive without hammering the API while it's quiet. - Duration display: render at second granularity — sub-second precision (283ms 200μs) is noise for task tracking, so anything under a second shows "<1s" and larger durations round to whole seconds. - Don't show a duration for pending tasks: a task that hasn't started has no execution time (queue time is not duration), so duration_seconds returns None until it starts.
|
Bito Automatic Review Skipped - Branch Excluded |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## gaq-to-gtf #43486 +/- ##
==============================================
- Coverage 78.91% 78.86% -0.06%
==============================================
Files 2884 2883 -1
Lines 165218 164874 -344
Branches 38159 38113 -46
==============================================
- Hits 130383 130028 -355
- Misses 32384 32399 +15
+ Partials 2451 2447 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…e same task get_statuses_changed_since returned max(changed_on) as the next cursor. With the inclusive >= bound, a task whose changed_on sits exactly at the cursor is re-delivered every poll, so max never advances — the cursor freezes, the same task is returned on every request, and the client-side backoff can't ramp down (it reads the re-delivery as fresh progress). An idle or orphaned in-progress task pins the poll at the eager interval indefinitely. Return the server clock captured *before* the read as the next cursor instead, so the watermark always advances; a change landing during the query is still caught next poll (>= is inclusive). Same naive-local clock as changed_on. Also confirm started_at/ended_at stay UTC (tz-aware) — the duration is computed server-side (Task.duration_seconds) and rendered from that, so no timezone mismatch reaches the client; the frontend never parses the raw timestamps.
Refine the task duration format: under a minute, show the seconds unit with up
to one decimal ("0.3s", "37.5s") instead of collapsing everything below a second
to "<1s". A minute or longer keeps the two highest *adjacent* whole units
("1m 30s", "2h 15m", "1d 2h") — and no longer skips a zero middle unit, so an
exact "1h 0m 5s" reads "1h" rather than "1h 5s".
…e-key hash Chart-data query tasks had no task_name, so the Task List showed the opaque query_cache_key hash. Set a friendly name at schedule time from the in-memory QueryContext — the chart (slice) name when available, else the dataset name — so the list reads "Sales by Region" rather than "879b1bc8586866…". Both are already loaded on the QueryContext, so this adds no metastore round trip; a multi-query chart disambiguates with a "(1)"/"(2)" suffix.
The Task List had a standalone "Dependencies" column; dependencies belong behind the chain-link icon in the Details column alongside Payload and the stack-trace / timeout indicators, shown only when there's something to report. Remove the column and render the dependency popover as a conditional Details icon. The "waiting on N prerequisites" state (a blocked PENDING task) folds into that icon — warning color + popover title — instead of a separate label.
|
/review |
There was a problem hiding this comment.
Code Review Agent Run #fd113b
Actionable Suggestions - 1
-
superset-frontend/src/middleware/asyncEvent.ts - 1
- Missing backoff integration tests · Line 184-192
Additional Suggestions - 2
-
superset-frontend/src/middleware/asyncEvent.ts - 1
-
No backoff on fetch error · Line 193-199On fetch error (line 198), the loop falls through and reschedules with the current currentPollDelayMs — potentially already doubled. A server-side error could be amplified by a rapid retry cycle. This is speculative; the server may have its own retry cap.
-
-
superset/tasks/async_queries.py - 1
-
Missing test for None name fallback · Line 192-208The `_task_name` function returns `None` when both `slice_name` and datasource name are absent (line 207), but there is no test coverage for this fallback path. Adding a test ensures this edge case is handled correctly and doesn't regress.
-
Review Details
-
Files reviewed - 13 · Commit Range:
c2968dd..9cdb791- superset-frontend/src/features/tasks/TaskDependenciesPopover.test.tsx
- superset-frontend/src/features/tasks/TaskDependenciesPopover.tsx
- superset-frontend/src/features/tasks/timeUtils.test.ts
- superset-frontend/src/features/tasks/timeUtils.ts
- superset-frontend/src/middleware/asyncEvent.test.ts
- superset-frontend/src/middleware/asyncEvent.ts
- superset-frontend/src/pages/TaskList/TaskList.test.tsx
- superset-frontend/src/pages/TaskList/index.tsx
- superset/daos/tasks.py
- superset/models/tasks.py
- superset/tasks/async_queries.py
- tests/unit_tests/tasks/test_async_queries.py
- tests/unit_tests/tasks/test_handlers.py
-
Files skipped - 0
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers an incremental AI Review. -
/review full- Manually triggers a full AI Review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| let progressed = false; | ||
| Object.entries(statuses).forEach(([taskId, { status }]) => { | ||
| if (waitersByTaskId.has(taskId)) progressed = true; | ||
| applyStatus(taskId, status); | ||
| }); | ||
| // Reset to eager on an awaited-task change; otherwise back off (bounded). | ||
| currentPollDelayMs = progressed | ||
| ? pollingDelayMs | ||
| : Math.min(currentPollDelayMs * 2, pollBackoffMaxMs); |
There was a problem hiding this comment.
The backoff behavior (lines 184–192) is described in comments and implemented in code, but asyncEvent.test.ts has no tests for the exponential delay progression or ensurePolling() wake/idempotent semantics. A future refactor could silently revert this logic without test coverage catching it.
Code Review Run #fd113b
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
… yet) A GTF timeout aborts the task, but chart-data queries have no abort handler to cancel the underlying warehouse query — so a timeout would only mark the task failed while the query kept running, and surfaced a "timeout without abort handler" warning in the Task List. Drop the timeout until query cancellation is implemented, then restore it.
…meout Make the async status-poll's two safety bounds operator-configurable instead of hardcoded: - GLOBAL_ASYNC_QUERIES_POLLING_MAX_DELAY (default 30s) — ceiling for the exponential backoff between polls while awaited tasks are quiet. - GLOBAL_ASYNC_QUERIES_POLLING_STALE_TIMEOUT (default 10m) — how long the client keeps polling with no progress on the tasks it is awaiting before giving up and rejecting them, so a stuck or orphaned task (e.g. a worker killed mid-execution) can't spin a chart — or the poll — forever. The clock resets on any awaited-task change, so steady progress is never interrupted. Both are read from the frontend bootstrap conf; the client falls back to the same defaults when absent.
SUMMARY
Targets
gaq-to-gtf. Polling and task-list display polish surfaced while testing async chart data on Postgres.Poll lifecycle — stop when idle, back off when quiet. The chart-data status poll previously rescheduled a heartbeat timer forever (no network when idle, but never truly stopped). Now:
/status_changeswhile it's quiet.Duration display at second granularity.
283ms 200μs-style output is noise for task tracking. Durations under a second now render as<1s; larger ones round to whole seconds (6m 6s).No duration for pending tasks. A task that hasn't started has no execution time (queue time isn't duration), so
duration_secondsreturnsNoneuntil it starts.TESTING INSTRUCTIONS
npm run test -- src/middleware/asyncEvent.test.ts— polling stops once all awaited tasks settle, and restarts for a new job after going idle.npm run test -- src/features/tasks/timeUtils.test.ts— sub-second →<1s, whole-second rounding.pytest tests/unit_tests/tasks/test_handlers.py -k duration— pending task has no duration.End-to-end: load an async dashboard and watch the network panel —
/status_changespolling ramps down while charts are slow and stops when all charts finish; reloading a fully-cached dashboard issues no polls.ADDITIONAL INFORMATION
GLOBAL_ASYNC_QUERIES