SPARK-1097: Do not introduce deadlock while fixing concurrency bug