How do you detect and prevent concurrent pipeline run conflicts?
Concurrent pipeline run conflicts happen when two or more workflow executions overlap and compete for a shared resource, output path, dataset partition, model registry entry, or deployment target. Running at the same time is not inherently wrong: the danger is unsafe shared state.
Question 65 introduced monitoring run IDs, logs and artifact lineage. Here the emphasis is detecting collisions and designing workflows so overlapping runs do not corrupt results or publish the wrong model.
Beginner-friendly practical example
A food-delivery business retrains a delivery-time predictor daily. The October 25 training run starts at 01:00 and needs 90 minutes, but a manually triggered run for October 26 starts at 01:30.
Both use an unsafe shared output path:
s3://models/delivery-time/latest/model.pkl- Run A: 01:00–02:30; dataset
orders-v25. - Run B: 01:30–03:00; dataset
orders-v26. - The two runs overlap for 60 minutes.
- If A uploads at 02:30 and B uploads at 03:00, the final object might be B's. But if uploads or completion order change, an older model can overwrite the newer model.
- A separate registry task might even read the other run's artifact, producing misleading lineage.
A safer layout gives each run its own immutable candidate:
s3://models/delivery-time/runs/run-A/model.pkl
s3://models/delivery-time/runs/run-B/model.pklEach evaluation consumes its own run-scoped artifact. A distinct *promotion step* decides which validated candidate becomes production, using a protected registry or deployment update rather than overwriting a shared path.
Where can runs conflict?
- Output paths: Two jobs write
latest.csv, the same object key, or the same unversioned model file. - Data partitions: Two feature jobs concurrently overwrite or append to the same logical date partition.
- Registry/deployment: Both jobs try to assign the same production alias or update the serving endpoint.
- Limited resources: Overlapping GPU-heavy runs starve one another or exceed quotas.
- External systems: Duplicate pipeline launches race to create the same remote training job.
- Mutable state: One job changes shared configuration while another is running.
Some overlaps are merely costly; others are correctness or safety bugs. Treat deployment and data corruption as higher priority than reducing run duration.
How do you detect conflicts?
- Attach a unique run ID to every task, log and artifact.
- Track the logical resource identity, such as
dataset=orders, partition=2026-10-25ormodel=delivery-time, target=production. - Detect two active runs claiming the same exclusive resource. Distinct dataset partitions may safely run in parallel.
- Alert on duplicate writes, optimistic-lock failures, overlapping promotions, unusual queue delays, and missing ownership information.
- Audit the final model registry or storage state to check which run actually produced what is live.
A sample structured event:
JSON{ "event": "resource_conflict", "resource": "model:delivery-time:production", "run_id": "run-B", "competing_run_id": "run-A", "resolution": "promotion_rejected_for_review" }
This event is illustrative; orchestration tools do not automatically emit it unless the team adds detection.
How do you prevent collisions?
1. Give outputs run-scoped identities. Store temporary and candidate outputs under immutable dataset and run IDs. Use stable checksums and record lineage.
2. Constrain run-level parallelism. For workflows that must never overlap, set a maximum of one active run. For example, in Apache Airflow:
PYTHONfrom airflow.sdk import dag, task from datetime import datetime, timezone @dag( schedule=None, start_date=datetime(2026, 10, 1, tzinfo=timezone.utc), max_active_runs=1, ) def delivery_training(): @task def train(): print("Run-scoped training work here") train() delivery_training()
This is a scheduling illustration rather than full model-training code. `max_active_runs=1` only restricts runs of that DAG; it does not prevent an independent DAG, external job, or another service from changing the same resource.
3. Protect shared resources across workflows. Use a transactional database constraint, atomic compare-and-swap or version check, lease/lock with expiry and fencing tokens, or an equivalent service-provided conflict-prevention mechanism. Locking must handle worker crashes; an expired lease alone can be unsafe when the old worker is still acting.
4. Separate candidate creation from promotion. Concurrent training may be desirable. Serialize or conditionally authorize production promotion based on evaluations and a controlled release policy.
5. Handle duplicate logical work. Choose a unique identity such as pipeline_version + snapshot_id + experiment_key. Reject or deduplicate simultaneous submissions of the same logical job unless repeated experiments are intended.
6. Limit expensive shared capacity. Airflow pools and task concurrency limits, or Kubeflow Pipelines recurring-run maximum concurrency, can restrict load. A GPU capacity limit is not the same as a data consistency guarantee.
What if two runs genuinely can run together?
If Run A works on the October 25 partition and Run B on October 26, and both use isolated artifacts, they may run concurrently. Keeping all ML pipelines sequential wastes compute. Apply resource-specific rules: parallelize independent preprocessing and training, but protect shared dataset partitions and production model aliases.
Testing the design
Start two runs simultaneously against the same logical dataset and production target in a staging environment. Confirm that candidates stay isolated, at most one authorized promotion wins, the losing run gets a clear conflict outcome, and all objects have accurate run lineage. Then simulate a crash after acquiring a lease or just before publishing.
In short: Detect concurrent conflicts by tracking which runs operate on which resources. Prevent them with isolated outputs, controlled concurrency, atomic conditional writes and guarded model promotion—without unnecessarily serializing independent ML work.
Sources & Research References
Learning Sequence
MLOps Curriculum
What is the difference between pipeline orchestration and data transformation?
Explore Related Questions
Deepen your understanding across related MLOps topics.