Dear all,
We have a pyspark streaming job (DBR: 14.3) that continuously writes new data on a Delta Table (TableA).
On this table, there is a pyspark batch job (DBR: 14.3) that operates every 15 minuted and in some cases it may delete some records from TableA using a merge statement (WhenMatchedDelete construct with a business related condition). This condition identifies specific records that are already present in TableA and it is impossible to match with records that are written during query execution.
Periodically, we get exceptions due to concurrency issues with the following trace:
{
"timestamp":1711718436569,
"userId":"xxx",
"userName":"xxx",
"operation":"STREAMING UPDATE",
"operationParameters":{
"outputMode":"Append",
"queryId":xxx,
"epochId":xxx,
"statsOnLoad":false
},
"job":{
"jobId":"xxx",
"jobName":"xxx",
"jobRunId":"xxx",
"runId":"xxx",
"jobOwnerId":"xxx",
"triggerType":"manual"
},
"notebook":{
"notebookId":"xxx"
},
"clusterId":"xxx",
"readVersion":21835,
"isolationLevel":"WriteSerializable",
"isBlindAppend":true,
"operationMetrics":{
"numRemovedFiles":"0",
"numOutputRows":"50",
"numOutputBytes":"25199",
"numAddedFiles":"1"
},
"tags":{
"restoresDeletedRows":"false",
"delta.rowTracking.preserved":"true"
},
"engineInfo":"Databricks-Runtime/14.3.x-scala2.12",
"txnId":"1eb445f1-2abd-4b6c-a8f0-3ccc1f2474f2"
}
As mentioned in this page: https://learn.microsoft.com/en-us/azure/databricks/optimizations/isolation-level, there should be no concurrency issue. Even after checking the limitations page (https://learn.microsoft.com/en-us/azure/databricks/optimizations/isolation-level#rlc-limitations) we follow all conditions
- No complex conditional clauses
- Explicit predicates that uniquely identify each record to be deleted
We suspect that this may have to do with this option: "delta.rowTracking.preserved":"true" but we were not able to locate any documentation about what this by default True configuration does. (only some github requests)
Please propose any mitigation actions for solving this concurrency issues as there may be some data inconsistencies to our ETL pipelines due to the aforementioned failures. Furthermore, this issue is not highlighted in the documentation per our understanding.
Thanks a-priori for your help.
Kind regards,
the European Dynamics team