Repository navigation
fix(gtf): address findings from the full-migration review - #43701
Conversation
Fixes the confirmed, contained findings from a full design+implementation review of the gaq-to-gtf epic: - HIGH: async chart-data dropped g.form_data in the worker, so Jinja-templated datasets rendered empty filter values — executing/caching the wrong SQL AND diverging query_cache_key from the submit-time task_key (cache-miss reschedule loop). Re-establish form data from the serialized payload (like the old GAQ task did). No unit test caught it because they all mock load_serialized_query; add regression tests asserting set_form_data is called. - Coordination: a transient redis.ConnectionError escaped the narrow retry arm and killed the abort/signal listener thread permanently. Degrade a RedisError in the blocking stream read to a predicate re-check (with backoff), fixing both the listener and the waiter. - Frontend: the sliding-window keepalive tore down + reopened a healthy socket, firing the open-listeners so every list view did a full row re-fetch each cycle. Tag opens with a reason (initial/reconnect/keepalive); list views reconcile only on a real reconnect. - Frontend: poll mode had no give-up/backoff on a persistent status_changes error (spun at the eager interval forever). Age toward the give-up and back off in the error path too. - GTF: the sync inline path never marked execution complete, so a late cancel could flip a finished task to ABORTED. Call mark_execution_completed after the body (success and exception), mirroring the async executor. Deferred (documented in the PR): multi-host status-poll clock skew, the timeout- path completion gating + dead _refresh_task fallback, failure-traceback persistence, and the insecure-by-default websocket cookie flags.
|
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. |
|
/review |
| // In-place merge, no full-list redraw. | ||
| const unsubscribeOpen = subscribeRealtimeOpen(reason => { | ||
| if (reason !== 'reconnect') return; | ||
| patchRows(collectionRef.current.map(rowId)); |
There was a problem hiding this comment.
Suggestion: patchRows runs outside latestRequestIdRef; its delayed response can merge an older reconnect snapshot after a newer page, filter, or refresh request completes. [race condition]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/views/CRUD/hooks.ts
**Line:** 350:350
**Comment:**
*Race Condition: `patchRows` runs outside `latestRequestIdRef`; its delayed response can merge an older reconnect snapshot after a newer page, filter, or refresh request completes.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Fixed in 799934d: patchRows now snapshots latestRequestIdRef.current before its fetch and discards the merge if a newer full fetch (page/filter/refresh) landed meanwhile, so a delayed reconcile can't overwrite fresher rows.
Code Review Agent Run #fb4d18Actionable Suggestions - 0Additional Suggestions - 5
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
The flagged race condition is a valid concern. When To resolve this, you should ensure that const requestId = latestRequestIdRef.current;
const result = await patchRows(...);
if (requestId === latestRequestIdRef.current) {
// Apply the result
}I have reviewed the available PR context. There are no other comments in the provided superset-frontend/src/views/CRUD/hooks.ts |
|
|
||
| # The work finished; stop the abort listener from flipping this to | ||
| # ABORTED if a cancel signal lands now (mirrors the async executor). | ||
| ctx.mark_execution_completed() |
There was a problem hiding this comment.
Suggestion: A timeout can fire after mark_execution_completed() but before cleanup, setting timeout_triggered and aborting already-finished work instead of leaving it successful. [race condition]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/tasks/decorators.py
**Line:** 518:518
**Comment:**
*Race Condition: A timeout can fire after `mark_execution_completed()` but before cleanup, setting `timeout_triggered` and aborting already-finished work instead of leaving it successful.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Fixed in 799934d: the timeout callback now elects under _abort_lock and skips when _execution_completed is set (mirroring _on_abort_detected), so a timeout firing after the body completes can't flip a finished task to TIMED_OUT.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## gaq-to-gtf #43701 +/- ##
============================================
Coverage 79.32% 79.32%
============================================
Files 2893 2892 -1
Lines 166784 166598 -186
Branches 38525 38481 -44
============================================
- Hits 132299 132162 -137
+ Misses 31981 31940 -41
+ Partials 2504 2496 -8
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:
|
- CI (sharded-jest) fix: the poll-mode give-up-on-error test used a fetch-mock 'throws' route, which SupersetClient retries over real timers (~3s), leaving a slow in-flight request that flaked across shards. Use a 400 (not retried) so it rejects deterministically in ~50ms. - keepalive can still mask a real disconnect as keepalive (external review): the timer guarded only on generation + socket===ws, but onclose merely *schedules* a reconnect without clearing socket, so a just-closed socket still matched. Add a readyState === OPEN guard (before the refresh GET and in .finally); a close just before keepalive now yields a 'reconnect' (list views reconcile) not a 'keepalive'. Test added. - patchRows race (CodeAnt): a delayed reconcile could merge a stale snapshot after a newer page/filter/refresh. Snapshot latestRequestIdRef and discard the merge if a newer full fetch landed meanwhile. - timeout after mark_execution_completed (CodeAnt): the timeout callback wasn't gated on _execution_completed (the abort listener is), so a timeout in the post-completion window flipped a finished task to TIMED_OUT. Elect under _abort_lock and skip when execution already completed.
|
Pushed CI ( Keepalive can still mask a real disconnect (external review). Correct — the timer only checked
Timeout after Tests: 462 Python task tests + the frontend middleware/CRUD/views suites green; ruff/mypy/oxfmt/oxlint clean on changed files. |
init() runs at module load and reads WEBSOCKET_ENABLE before the feature-flag gate. When bootstrap carries no conf (e.g. a component test with no data-bootstrap) config is undefined, so `config.WEBSOCKET_ENABLE` threw at import — failing every test file that transitively imports asyncEvent (the broad multi-shard jest failure). Read it defensively (`config?.WEBSOCKET_ENABLE`) and add a regression test that init() with no conf does not throw.
|
Found and fixed the real CI cause in Root cause: Remaining two failures are pre-existing / flaky, not from this PR:
Verified locally: |
There was a problem hiding this comment.
Pull request overview
Closes a set of confirmed correctness regressions and edge cases found during the gaq-to-gtf full-migration review, spanning backend task execution/coordination reliability and frontend realtime/polling behavior. The changes harden the GTF async chart-data worker context and reduce spurious refresh/reconcile loops, with targeted unit tests added for each fix.
Changes:
- Backend: re-establish
g.form_datain async chart-data workers; ensure inline (sync) task execution marks completion to prevent late cancel/timeout races; degrade Redis stream read failures to predicate re-check with bounded backoff. - Frontend realtime: tag socket OPEN events with a reason (
initial/reconnect/keepalive) to avoid expensive “reconcile on keepalive”; guard keepalive handoff to only operate on truly OPEN sockets. - Frontend polling: make poll-mode backoff/give-up apply to persistent fetch errors (not just “no progress”), and make
asyncEvent.init()resilient to missing bootstrapconf.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit_tests/tasks/test_decorators.py | Adds regression test asserting inline execution marks execution_completed after the body runs. |
| tests/unit_tests/tasks/test_async_queries.py | Adds worker form-data re-establishment tests (including None→{} default). |
| tests/unit_tests/coordination/test_service.py | Adds coverage for transient Redis ConnectionError degrading instead of killing the waiter. |
| superset/tasks/decorators.py | Marks inline task execution completed before terminal-state decision; also in exception path. |
| superset/tasks/context.py | Makes timeout election consistent with abort election and completion gating under the abort lock. |
| superset/tasks/async_queries.py | Restores g.form_data in async chart-data worker from serialized payload. |
| superset/coordination/base.py | Treats any RedisError during blocking stream reads as non-fatal with bounded backoff. |
| superset-frontend/src/views/CRUD/hooks.ts | Avoids realtime list reconcile on keepalive; adds stale-patch discard via request id snapshot. |
| superset-frontend/src/views/CRUD/hooks.test.tsx | Adds test ensuring list views do not reconcile on keepalive reconnects. |
| superset-frontend/src/middleware/realtime.ts | Introduces RealtimeOpenReason and threads it through open-listeners; tightens keepalive handoff guards. |
| superset-frontend/src/middleware/realtime.test.ts | Extends keepalive coverage and adds drop-before-keepalive regression test ensuring “real reconnect” semantics. |
| superset-frontend/src/middleware/asyncEvent.ts | Shares backoff/give-up logic between “no progress” and fetch-error paths; defensive read of bootstrap conf. |
| superset-frontend/src/middleware/asyncEvent.test.ts | Adds regression tests for missing bootstrap conf and poll-mode give-up on persistent status_changes errors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
SUMMARY
A full design + implementation review of the
gaq-to-gtfepic (7 parallel subsystem reviewers across coordination, the GTF core, task commands/DAO/models, the chart-data cutover, the websocket transport, the frontend, and security) turned up one HIGH regression and a set of MEDIUM edge-case correctness items. The security review came back clean (no in-scope boundary violation). This PR fixes the confirmed, contained findings; each is covered by a test.Why this matters. The epic is architecturally sound, but the review found a real regression that would break a whole class of dashboards and several "something fired late/again after the work finished" edge cases that undermine the correctness properties the framework exists to guarantee. Better to close them before the epic merges to master.
Fixed
HIGH — async chart-data dropped
g.form_data.execute_chart_querynever re-established form data in the worker (the old GAQ task calledset_form_data).get_form_data()falls back tog.form_data"for cache warmup and async queries", and Jinjafilter_values/get_filters/get_time_filterread through it — so a Jinja-templated dataset rendered empty filter values in the worker, both executing/caching the wrong SQL and computing aquery_cache_keythat diverges from the submit-timetask_key, so the client's re-request never reads back the cache the task wrote (cache-miss reschedule loop). Fix: re-establish form data from the serialized payload. Every existing unit test mockedload_serialized_query, so nothing exercised this path — added regression tests assertingset_form_datais called with the payload's form data. (A templated-dataset end-to-end integration test is the durable guard and is called out as a follow-up; the existing async integration test is@unittest.skip-ped as MySQL-flaky.)MEDIUM — coordination signal listener died on a transient
ConnectionError._read_streamcaught only(RedisTimeoutError, OSError); aredis.ConnectionErrorescaped to_run_listen_loop's broad except, which logged "crashed" and let the abort/signal listener thread exit permanently, so a live task might not honor a user-cancel until its GTF timeout. Fix: degrade anyRedisErrorin the blocking read to a predicate re-check (with a bounded backoff so it can't busy-spin) — this fixes both the background listener andwait_for_signal, matching the "reconnect/failover-resilient" contract.MEDIUM — keepalive turned "reconcile on drop" into a periodic full reconcile. The sliding-window keepalive tears down + reopens a healthy socket every ~0.6×lifetime, firing the open-listeners — so every list view did a full displayed-row re-fetch each cycle, re-adding the load the no-polling design set out to avoid. Fix: tag each socket open with a
reason(initial/reconnect/keepalive); list views reconcile only on a realreconnect. Chart-data catch-up still runs on all opens (it's cheap and coalesced, and covers the sub-second keepalive handover).MEDIUM — poll mode never gave up on a persistent fetch error. The stale-timeout give-up lived only in the success branch; the
catchjust logged and rescheduled at the eager 500ms interval, andgiveUpIdis WS-mode-only — so a websocket-off chart could spin forever (hammering a degraded endpoint) ifstatus_changesfailed persistently. Fix: the error path now ages toward the same give-up and backs off.MEDIUM — sync inline path could flip a finished task to ABORTED.
_execute_inlinenever calledctx.mark_execution_completed()(the async executor does), so a cancel signal detected after the body completed still ran the abort branch. Fix: mark completion after the body in both the success and exception paths, mirroring the async executor.Deferred (follow-ups, with rationale)
get_statuses_changed_sinceuses host-localchanged_on >= cursor). Real for multi-host, but the fix (move the cursor to the DB clock) is invasive and touches cursor semantics; matters mainly in websocket-off deployments. Tracked as a follow-up._refresh_taskfallback (GTF core): narrow windows, and chart-data async uses the guarded path. Deferred to keep this PR focused on the confirmed, contained fixes.SameSite=NonewithoutSecure; origin allowlist off): operator configuration; worth a docs/default hardening pass separately.SECURITY.md(optional privacy hardening).TESTING INSTRUCTIONS
pytest tests/unit_tests/tasks tests/unit_tests/coordination(492 pass; new coverage forset_form_datare-establishment, the coordination connection-error degrade, and the syncmark_execution_completed).npm run test -- asyncEvent realtime hooks(new coverage for poll-mode give-up on persistent error, list-view no-reconcile on keepalive, and the keepalive-vs-reconnect reason).gaq-to-gtffailures).ADDITIONAL INFORMATION