Saturday
How do you handle situations where multiple Databricks jobs need to update the same Delta table at the same time?
Even when the jobs are updating different sets of records, concurrent modification errors can still occur.
Can row-level concurrency completely address this issue, or are there situations where we still need to implement retry logic or change the table design?
Scheduling all the jobs sequentially would significantly increase the overall processing time.
Saturday
Row-level concurrency removes most of these errors, but it doesn't remove all of them. You still need retry logic. It only turns on when all of these are true:
If any of these is missing, conflicts are still detected per file. Two MERGEs that touch different rows in the same file will still conflict.
Even with row-level concurrency on, you can still get conflicts in these cases:
This is what I'd do:
ALTER TABLE target SET TBLPROPERTIES ('delta.enableDeletionVectors' = true);
-- prefer liquid clustering over partitioning for concurrent writers
ALTER TABLE target CLUSTER BY (business_key);import time, random
from delta.exceptions import ConcurrentAppendException, ConcurrentDeleteReadException
for attempt in range(5):
try:
run_merge()
break
except (ConcurrentAppendException, ConcurrentDeleteReadException):
time.sleep(2 ** attempt + random.random())
else:
raiseDocs: https://docs.databricks.com/aws/en/optimizations/isolation/row-level-concurrency
Can you share these details? - What's the exact exception (ConcurrentAppendException, ConcurrentDeleteReadException, etc.) and which runtime version are you on? - Is the target table partitioned, and are deletion vectors enabled? You can check with DESCRIBE DETAIL and SHOW TBLPROPERTIES.
Sunday
Delta Lake uses optimistic concurrency control - the MERGE runs without locks. It reads a snapshot, rewrites the affected data files and only at commit time checks whether another transaction changed anything it touched. If two jobs rewrite the same data file, the commit check fails even when they update completely different rows because Delta's default conflict detection works at file granularity. A second failure mode is DELTA_CONCURRENT_APPEND - a MERGE whose scan overlaps files that another job appended after the snapshot began - so even disjoint jobs can collide when the merge condition can scan the whole table. These are correctness features and the losing transaction is rolled back to prevent data corruption.
You can run jobs in parallel safely though. Enable row level concurrency - it detects changes at row level and auto-resolves concurrent MERGE/UPDATE/DELETE jobs that touch different rows. It's active by default when the table is unpartitioned with deletion vectors enabled (or liquid clustered) on new runtimes. Note partitioned tables do not get row level concurrency. Use liquid clustering and keep an idempotent retry-with-backoff wrapper as a safety net to avoid conflicts.
-- enable deletion vectors
ALTER TABLE main.analytics.customers SET TBLPROPERTIES ('delta.enableDeletionVectors' = true)
-- liquid clustering
CREATE TABLE main.analytics.customers (
customer_id BIGINT, status STRING, updated_at TIMESTAMP
) CLUSTER BY (customer_id)
Sunday
Delta Lake uses optimistic concurrency control, so concurrent MERGE operations can conflict even when they update different records, particularly when those records reside in the same underlying data files.
Row-level concurrency significantly reduces these conflicts, but it does not eliminate them completely.
1. Enable row-level concurrency
Row-level concurrency requires a supported Databricks Runtime and an unpartitioned Delta table with deletion vectors enabled.
ALTER TABLE catalog.schema.customers
SET TBLPROPERTIES (
'delta.enableDeletionVectors' = 'true'
);Liquid Clustered tables can also support row-level concurrency.
For example, if Job A updates customer 101 and Job B updates customer 102 within the same data file, row-level concurrency can allow both operations to succeed.
However, conflicts can still occur when both jobs modify the same row or when concurrent operations change table metadata.
I would recommend Databricks Runtime 14.3 LTS or above for this approach.
2. Implement bounded retry logic
Configure Lakeflow Jobs with a limited number of retries and a retry interval to handle temporary concurrency conflicts.
Ensure the MERGE operation is idempotent so retrying it does not introduce duplicates or overwrite newer records with older values.
3. Optimize the MERGE condition
For workloads operating on independent business regions, explicitly restrict the target scope.
MERGE INTO customers AS t USING source_india AS s ON t.customer_id = s.customer_id AND t.region = 'India' WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT *;
This assumes the source contains only Indian customers and region is a stable part of the matching logic.
4. Consider a centralized MERGE pattern
If conflicts remain frequent, allow multiple jobs to write independently to staging tables and use a dedicated job to consolidate those changes into the target table.
My recommendation is to combine row-level concurrency, bounded retries and non-overlapping write scopes. There is no need to make the entire pipeline sequential just to avoid write conflicts.
Could you confirm whether the target table is partitioned and whether deletion vectors are enabled?
Official references:
Saturday
Row-level concurrency removes most of these errors, but it doesn't remove all of them. You still need retry logic. It only turns on when all of these are true:
If any of these is missing, conflicts are still detected per file. Two MERGEs that touch different rows in the same file will still conflict.
Even with row-level concurrency on, you can still get conflicts in these cases:
This is what I'd do:
ALTER TABLE target SET TBLPROPERTIES ('delta.enableDeletionVectors' = true);
-- prefer liquid clustering over partitioning for concurrent writers
ALTER TABLE target CLUSTER BY (business_key);import time, random
from delta.exceptions import ConcurrentAppendException, ConcurrentDeleteReadException
for attempt in range(5):
try:
run_merge()
break
except (ConcurrentAppendException, ConcurrentDeleteReadException):
time.sleep(2 ** attempt + random.random())
else:
raiseDocs: https://docs.databricks.com/aws/en/optimizations/isolation/row-level-concurrency
Can you share these details? - What's the exact exception (ConcurrentAppendException, ConcurrentDeleteReadException, etc.) and which runtime version are you on? - Is the target table partitioned, and are deletion vectors enabled? You can check with DESCRIBE DETAIL and SHOW TBLPROPERTIES.
Sunday
Delta Lake uses optimistic concurrency control - the MERGE runs without locks. It reads a snapshot, rewrites the affected data files and only at commit time checks whether another transaction changed anything it touched. If two jobs rewrite the same data file, the commit check fails even when they update completely different rows because Delta's default conflict detection works at file granularity. A second failure mode is DELTA_CONCURRENT_APPEND - a MERGE whose scan overlaps files that another job appended after the snapshot began - so even disjoint jobs can collide when the merge condition can scan the whole table. These are correctness features and the losing transaction is rolled back to prevent data corruption.
You can run jobs in parallel safely though. Enable row level concurrency - it detects changes at row level and auto-resolves concurrent MERGE/UPDATE/DELETE jobs that touch different rows. It's active by default when the table is unpartitioned with deletion vectors enabled (or liquid clustered) on new runtimes. Note partitioned tables do not get row level concurrency. Use liquid clustering and keep an idempotent retry-with-backoff wrapper as a safety net to avoid conflicts.
-- enable deletion vectors
ALTER TABLE main.analytics.customers SET TBLPROPERTIES ('delta.enableDeletionVectors' = true)
-- liquid clustering
CREATE TABLE main.analytics.customers (
customer_id BIGINT, status STRING, updated_at TIMESTAMP
) CLUSTER BY (customer_id)
Sunday
Delta Lake uses optimistic concurrency control, so concurrent MERGE operations can conflict even when they update different records, particularly when those records reside in the same underlying data files.
Row-level concurrency significantly reduces these conflicts, but it does not eliminate them completely.
1. Enable row-level concurrency
Row-level concurrency requires a supported Databricks Runtime and an unpartitioned Delta table with deletion vectors enabled.
ALTER TABLE catalog.schema.customers
SET TBLPROPERTIES (
'delta.enableDeletionVectors' = 'true'
);Liquid Clustered tables can also support row-level concurrency.
For example, if Job A updates customer 101 and Job B updates customer 102 within the same data file, row-level concurrency can allow both operations to succeed.
However, conflicts can still occur when both jobs modify the same row or when concurrent operations change table metadata.
I would recommend Databricks Runtime 14.3 LTS or above for this approach.
2. Implement bounded retry logic
Configure Lakeflow Jobs with a limited number of retries and a retry interval to handle temporary concurrency conflicts.
Ensure the MERGE operation is idempotent so retrying it does not introduce duplicates or overwrite newer records with older values.
3. Optimize the MERGE condition
For workloads operating on independent business regions, explicitly restrict the target scope.
MERGE INTO customers AS t USING source_india AS s ON t.customer_id = s.customer_id AND t.region = 'India' WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT *;
This assumes the source contains only Indian customers and region is a stable part of the matching logic.
4. Consider a centralized MERGE pattern
If conflicts remain frequent, allow multiple jobs to write independently to staging tables and use a dedicated job to consolidate those changes into the target table.
My recommendation is to combine row-level concurrency, bounded retries and non-overlapping write scopes. There is no need to make the entire pipeline sequential just to avoid write conflicts.
Could you confirm whether the target table is partitioned and whether deletion vectors are enabled?
Official references: