Databricks Data Engineer Professional Question 18
Select 2You are working on a Delta Lake table that is updated frequently by multiple streaming and batch jobs. Delta Lake uses Optimistic Concurrency Control (OCC) to manage concurrent transactions. Which of the following scenarios could result in a transaction conflict due to OCC?
- A
Two transactions attempt to update the same set of rows simultaneously.
- B
One transaction attempts to delete rows while another transaction reads the same rows.
- C
Two transactions attempt to add new rows to the table concurrently.
- D
One transaction updates rows that were inserted by another in-flight transaction.
- E
A transaction reads rows that are being updated by another transaction.
Show answer and explanation
Correct answers: A, D
Explanation
Delta Lake's Optimistic Concurrency Control (OCC) ensures isolation by checking for conflicts at the commit phase instead of during transaction execution. Conflicts occur when two or more transactions attempt to modify the same data (e.g., rows being updated or deleted), as Delta Lake detects overlapping changes. However, reads are isolated from writes, so read operations do not conflict with writes, and concurrent appends are also supported without conflicts.
- A. Correct.
Correct: Delta Lake's OCC checks for conflicts when two transactions attempt to update the same rows. This can result in a conflict because both transactions are modifying the same data.
- B. Incorrect.
Incorrect: A delete operation and a read operation do not conflict in Delta Lake because reads are isolated from writes due to snapshot isolation.
- C. Incorrect.
Incorrect: Adding new rows concurrently does not conflict in Delta Lake because each transaction adds data to different parts of the table, and there is no overlap in the data being modified.
- D. Correct.
Correct: A conflict arises when one transaction updates rows that were affected by another in-flight transaction, as Delta Lake detects overlapping modifications during the commit phase.
- E. Incorrect.
Incorrect: Reads are isolated from writes in Delta Lake, so a transaction reading rows does not conflict with another transaction updating those rows.