We are getting UNABLE_TO_LOCK_ROW error couple time a week. This time I was able to get the logs of it by setting user trace flag on production. When I check the logs, I see that a single SOQL query took 15 seconds.
When I check successful transactions, I can see this specific query takes around 400-500ms (still much longer than others but not this magnitude).
The question is, what might be the reason for a single query to take this long?
Also, to solve this particular problem, my initial thought was caching the query results but since I don’t know what causes it, not sure if caching would be the solution.
Read more here: Source link