villebro opened a new pull request, #43557: URL: https://github.com/apache/superset/pull/43557
### SUMMARY In the Task List, a **running** task's Duration was inflated by the viewer's UTC offset (e.g. ~7h in PDT). The value is already sent to the client as a number (`duration_seconds`), so this was not a client-side TZ parse — the bug was server-side. **Root cause.** `Task.started_at`/`ended_at` were written as *aware* UTC (`datetime.now(timezone.utc)`) into *naive* `DateTime` columns. On a DB/driver that converts aware datetimes to the session-local timezone when writing to a naive column (classic MySQL behavior), `started_at` was persisted as local wall-clock; `Task.duration_seconds` then relabeled it UTC (`.replace(tzinfo=timezone.utc)`) for the still-running delta, inflating the elapsed by the local offset. Finished tasks were immune (both endpoints share the convention). **Fix.** - Store `started_at`/`ended_at` as **naive UTC** (`datetime.now(timezone.utc).replace(tzinfo=None)`) in `Task.set_status` and `TaskDAO.conditional_status_update`, and compute `duration_seconds` against a naive-UTC `now`, defensively stripping any tzinfo for legacy rows. No driver tz-conversion can skew it now. - Add a `LiveDuration` component that ticks a running task's Duration upward once per second **when the realtime websocket transport is enabled** (`WEBSOCKET_ENABLE`, already permission-masked). It anchors on the server's `duration_seconds` plus locally-measured elapsed — it never parses an absolute server timestamp, so it can't reintroduce a TZ offset. When websocket is off, the Duration renders statically and refreshes on each poll. Deferred (not in this PR): rendering `created_on` client-side. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A ### TESTING INSTRUCTIONS ```bash pytest tests/unit_tests/tasks/test_handlers.py -q npm run test -- src/features/tasks/LiveDuration.test.tsx src/pages/TaskList/TaskList.test.tsx ``` Manual: with `WEBSOCKET_ENABLE` on and a slow task, the running Duration starts from a correct small value and ticks up ~1s/s; with websocket off, Duration is correct and static, refreshing on each poll. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [x] Required feature flags: `GLOBAL_ASYNC_QUERIES` / `GLOBAL_TASK_FRAMEWORK` (no new flags) - [x] Changes UI - [ ] Includes DB Migration - [ ] Introduces new feature or API - [ ] Removes existing feature or API Targets the `gaq-to-gtf` epic branch. Part of #43407. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
