fix: cleanup cleanup_workflow_concurrency_slots bug#3318
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Benchmark resultsCompared against |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a PostgreSQL cleanup function so workflow-level concurrency slots can be deleted even when the underlying v1_task rows have been purged, preventing orphaned workflow concurrency slots from accumulating.
Changes:
- Updates
cleanup_workflow_concurrency_slotsto allow cleanup whenrelevant_tasks_for_dagsis empty (post-purge case). - Adds an integration regression test covering chained strategies and task purge behavior.
- Adds a goose migration to roll out the function fix to existing databases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sql/schema/v1-core.sql | Adjusts the cleanup function guard to handle COUNT(*) = 0 correctly. |
| pkg/scheduling/v1/concurrency_integration_test.go | Adds a regression test that simulates task purge and asserts workflow slots are cleaned up. |
| cmd/hatchet-migrate/migrate/migrations/20260318190742_v1_0_90_fix_orphaned_workflow_concurrency_slots.sql | Applies the function fix via migration (with Down restoring prior behavior). |
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+918
to
923
| AND ( | ||
| (SELECT COUNT(*) FROM relevant_tasks_for_dags) = 0 | ||
| OR CARDINALITY(wcs.child_strategy_ids) <= ( | ||
| SELECT COUNT(*) FROM relevant_tasks_for_dags | ||
| ) | ||
| ) |
Comment on lines
+279
to
+287
| sort.Slice(strategies, func(i, j int) bool { | ||
| return strategies[i].ID < strategies[j].ID | ||
| }) | ||
|
|
||
| stratCIP := strategies[0] | ||
| stratGRR := strategies[1] | ||
|
|
||
| require.Equal(t, sqlcv1.V1ConcurrencyStrategyCANCELINPROGRESS, stratCIP.Strategy) | ||
| require.Equal(t, sqlcv1.V1ConcurrencyStrategyGROUPROUNDROBIN, stratGRR.Strategy) |
Comment on lines
+59
to
+64
| AND ( | ||
| (SELECT COUNT(*) FROM relevant_tasks_for_dags) = 0 | ||
| OR CARDINALITY(wcs.child_strategy_ids) <= ( | ||
| SELECT COUNT(*) FROM relevant_tasks_for_dags | ||
| ) | ||
| ) |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
cleanup_workflow_concurrency_slots has a CARDINALITY(child_strategy_ids) <= COUNT(tasks) guard that prevents premature cleanup during DAG execution. But when cancelled tasks are purged from v1_task, the count drops to 0 and CARDINALITY <= 0 is always false -- so the workflow concurrency slot is never deleted.
Type of change