Repository navigation
feat(gtf): Task List type/name filters + worker self-fencing on lost metastore contact - #43659
Conversation
Change the Task List 'Type' filter from a free-text contains match to a
select dropdown populated from distinct task types, and add a new 'Name'
free-text (contains) filter.
Backend: expose the BaseSupersetModelRestApi /distinct/<column> endpoint on
TaskRestApi (allowed_distinct_fields = {"task_type"}); it applies base_filters
so the dropdown is scoped per-user like the list itself.
The reaper handles a dead worker, but a worker that is alive yet cut off from the metastore (network partition, metastore outage) would keep running a query the reaper has already marked FAILURE. Add worker-side self-fencing: if heartbeat writes keep failing for longer than GTF_ORPHAN_TASK_TIMEOUT (the same window the reaper uses), the worker fails the task from the inside, cancelling any in-flight query via the existing abort path. A single failed write is tolerated; only a sustained outage spanning the orphan window fences, so a transient blip never kills a healthy task. There is no handover — the task simply fails (kept the 'heartbeat' framing rather than 'lease' for that reason). - heartbeat.py: task_heartbeat tracks a deadline and yields a HeartbeatController; on sustained write failure it invokes the fence callback and emits gtf.task.self_fenced. - context.py: extract _abort_locally (shared by the timeout timer) and add trigger_self_fence + fence_triggered; a fence marks the task for FAILURE. - scheduler.py: wire the fence callback to the context and finalize a fenced task as FAILURE. No schema change: builds on the existing last_heartbeat column and GTF_ORPHAN_TASK_TIMEOUT.
- context.py: trigger_self_fence now guards on _execution_completed (mirrors _on_abort_detected) so a fence racing in after successful completion cannot clobber the result; add an aborting_in_flight property and use it at the two executor guard sites. - heartbeat.py: extract _new_deadline() (DRY the three resets); add HeartbeatController.invoke_fence() to drop the private-access lint noise. - tests: cover the partition path where the ABORTING write raises but handlers still run; a fence after execution-completed is a no-op; and an intermittent fail/success heartbeat does not fence (the 'transient blip tolerated' promise).
|
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. |
The Task column overrode its accessor with id: 'task', but ListView validates each filter's id against column ids/accessors and uses filter.id as the API query column. The new task_name filter therefore threw 'Invalid filter config, task_name is not present in columns'. Align the column id with its accessor (matching the status/task_type/scope columns); no functional change to the column, which already rendered task_name.
…tasklist-type-filter # Conflicts: # docs/developer_docs/extensions/tasks.md # superset/config.py
|
/review |
Code Review Agent Run #fe5deaActionable 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## gaq-to-gtf #43659 +/- ##
=============================================
Coverage ? 79.28%
=============================================
Files ? 2890
Lines ? 166487
Branches ? 38464
=============================================
Hits ? 131999
Misses ? 32007
Partials ? 2481
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:
|
Addresses a full design + docs re-review of the GTF resilience mechanisms. Design: - R1 (reaper): claim the FAILURE transition via CAS *before* firing destructive cleanup. Revoke and out-of-band query cancellation now run only after the reaper wins the CAS, so a briefly-stalled-but-healthy worker that revives and commits its own terminal status keeps its warehouse query (no false-positive kill, which would also cascade FAILURE to dependents). - R2 (context): elect the abort/timeout/self-fence winner under a lock so abort handlers run exactly once across the three daemon threads (listener, timeout timer, heartbeat) that can race to abort. - R3 (DAO): anchor the heartbeat write and the orphan scan on the *database* clock (dialect-aware naive-UTC now, app-side fallback) so worker/reaper host clock skew can't reap a live task early. - R5 (heartbeat): only self-fence once the fence callback is armed (task is executing); a stalled heartbeat during the pre-execution DAG wait keeps retrying so recovered connectivity resumes the task instead of forfeiting it. Docs: - Document get_dependency_payloads() (+ the immediate=True pairing), add a reap_orphaned_tasks beat-schedule snippet, name the TASK_PROGRESS_UPDATE_THROTTLE_INTERVAL / TASK_ABORT_POLLING_DEFAULT_INTERVAL tunables, and note orphan-reap/self-fence as FAILURE causes. - Fix stale 'prune cron reaps' comments (reap.py, models/tasks.py, migration). Tests: reaper no longer cancels/revokes on a lost CAS; concurrent abort election runs handlers once; heartbeat does not fence before armed.
SUMMARY
Three related Global Task Framework (GTF) improvements against the
gaq-to-gtffeature branch, plus the design/docs hardening that came out of a full pre-merge re-review.1. Task List filters
containsmatch to a select dropdown populated from the distinct task types actually present. This exposes theBaseSupersetModelRestApi/distinct/<column>endpoint onTaskRestApi(allowed_distinct_fields = {"task_type"}); it appliesbase_filters, so the dropdown is scoped per-user exactly like the list itself.contains) filter is added.idis aligned with itstask_nameaccessor (it previously overrode toid: 'task'), which is whatListViewvalidates filters against.2. Worker self-fencing on lost metastore contact
The reaper (#43658) handles a dead worker, but a worker that is alive yet cut off from the metastore (network partition, metastore outage) would keep running a query the reaper has already — or will shortly — mark
FAILURE. This adds the worker-side complement:tasks.last_heartbeat. If those writes keep failing for longer thanGTF_ORPHAN_TASK_TIMEOUT— the same window the reaper uses — the worker fails the task from the inside, cancelling any in-flight query via the existing abort path (a fresh connection to the warehouse, reachable even when the metastore is not).execute_taskexecutor for every GTF task type. Proactively interrupting a blocked task still requires anon_aborthandler (same as timeouts/user-cancel); chart-data tasks register one.last_heartbeatcolumn andGTF_ORPHAN_TASK_TIMEOUT.3. Resilience-design hardening (from the pre-merge re-review)
FAILUREtransition via compare-and-swap before firing destructive cleanup.revokeand out-of-band query cancellation run only after it wins the CAS, so a briefly-stalled-but-healthy worker that revives and commits its own terminal status keeps its warehouse query — avoiding a false-positive kill (which would cascadeFAILUREto all dependents).Docs: the Tasks developer doc gains
get_dependency_payloads()(+ theimmediate=Truepairing), areap_orphaned_tasksbeat-schedule snippet, the previously-unnamedTASK_PROGRESS_UPDATE_THROTTLE_INTERVAL/TASK_ABORT_POLLING_DEFAULT_INTERVALtunables, and orphan-reap/self-fence noted asFAILUREcauses. Stale "prune cron reaps" comments (reap command, model, migration) are corrected toreap_orphaned_tasks.Two low-severity review items are documented rather than changed: post-terminal property writes are harmless (the status column is CAS-fenced), and implicit-cancel engines have a slightly larger uncancellable set than SQL Lab — both match the documented contract.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Task List "Type" filter is now a dropdown of the distinct task types, plus a new free-text "Name" filter. (Screenshots to add.)
TESTING INSTRUCTIONS
GLOBAL_TASK_FRAMEWORKenabled; Type is a dropdown of distinct task types (scoped to tasks you can see), and Name does a substring match.DISTRIBUTED_COORDINATION_CONFIG, start an async chart query, then sever the worker's connection to the metastore for longer thanGTF_ORPHAN_TASK_TIMEOUT. The worker fails the task from the inside and the backend query disappears frompg_stat_activity; a brief blip shorter than the window does not fence.pytest tests/unit_tests/tasks/(429 tests) — heartbeat self-fence/arming/blip-tolerance,TaskContext.trigger_self_fence+ concurrent abort election, executor fence-finalization, and reaper CAS-then-cleanup ordering.ADDITIONAL INFORMATION
GLOBAL_TASK_FRAMEWORK