Databricks Data Engineer Professional Question 15
Single answerA data engineering team is using Delta Lake's Optimistic Concurrency Control (OCC) to manage data modifications in a shared Delta table. Two concurrent transactions are initiated: Transaction A updates specific rows in the table, while Transaction B concurrently deletes some of the rows that Transaction A is updating. How does Delta Lake's OCC handle this scenario, and which transactions are likely to conflict?
- A
Both transactions will succeed without any conflicts because Delta Lake automatically resolves conflicts between updates and deletes.
- B
Transaction A will fail due to a conflict, while Transaction B will succeed because deletes take precedence over updates in Delta Lake.
- C
Both transactions will fail because Delta Lake does not permit any concurrent modifications on the same rows.
- D
One transaction will succeed, and the other will fail due to a write conflict detected by Delta Lake's Optimistic Concurrency Control.
Show answer and explanation
Correct answer: D
Explanation
Delta Lake's Optimistic Concurrency Control ensures isolation by validating that no two transactions modify the same data concurrently. In this scenario, Transactions A and B conflict because they both attempt to modify the same rows. OCC detects this write conflict and allows only one transaction to succeed while the other fails. This behavior ensures data consistency and adheres to ACID principles.
- A. Incorrect.
This is incorrect. Delta Lake cannot automatically resolve conflicts between updates and deletes because they modify the same rows. OCC explicitly detects this conflict.
- B. Incorrect.
This is incorrect. Delta Lake's OCC does not prioritize deletes over updates. Instead, it detects overlapping modifications and ensures that only one transaction succeeds.
- C. Incorrect.
This is incorrect. Delta Lake allows concurrent modifications as long as they do not overlap. However, if two transactions modify the same rows, OCC will detect the conflict and fail one of them.
- D. Correct.
This is correct. Delta Lake's Optimistic Concurrency Control detects write conflicts when two transactions modify the same rows and ensures that only one transaction commits successfully, while the other fails.