#6475 Add workflow concurrency control
Pull request opened by
thomasjhuang
## Tracking issue
This solves
#5659 and also closes out
#6309. The related flytekit change is here -
flyteorg/flytekit#3267.
## Why are the changes needed?
This work is to provide workflow concurrency control at a project/domain/wf_name level (across all versions). This is a user requested feature to primarily limit workflow concurrency to 1 in order to provide more stable data consistency and ETL. For example, if we create a cron schedule to execute some workflow every 15 min. but sometimes the workflow takes 20 min. to execute (which happens a lot, wf termination durations are non-deterministic due to async execution nature of Flyte) then there can be another workflow of the same version that overlaps the original one. This can cause problems if the data artifacts or inputs/outputs have some time-based feature for example. If we can guarantee that X is the max concurrency then users can always expect this to be the limit and ETL their pipeline with better guarantees of data correctness and consistency.
## What changes were proposed in this pull request?
The primary mechanism is fairly straightforward - whenever we attempt to launch an execution, make a db query to check for running executions given the NamedEntityIdentifier triplet (project/domain/wf_name), and if the running executions is above the threshold for concurrency (
max_concurrency
) then we immediately fail to create the execution.
## How was this patch tested?
Unit tests added to execution_manager_test.go, but namely this was internally tested at LinkedIn since we are porting this feature externally.
More testing is in progress on local sandbox.
### Labels
•
added:
ConcurrencyPolicy
and logic surrounding workflow concurrency management, as well as db migration to add an index on
executions
table for
execution_phase
.
### Setup process
### Screenshots
## Check all the applicable boxes
• I updated the documentation accordingly.
• All new and existing tests passed.
• All commits are signed-off.
## Related PRs
#5659 and
#6309, will also add in flytekit PR as reference.
## Docs link
• Will add in docs
https://bito.ai#summarystart|
### Summary by Bito
This pull request introduces a new feature for managing workflow concurrency, allowing users to set limits on concurrent executions at the project, domain, and workflow name levels. It includes a ConcurrencyPolicy to enforce these limits, logic to check for running executions, and database migrations to enhance performance and ensure data consistency during workflows.
flyteorg/flyte