My custom code is executed using a queuable class. Sometime it runs perfectly, other times it gives this error:
Failed to update list. Error: System.DmlException: Update failed. First exception on row 0 with id a0fW0000000kws9IAA; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 1 records: 003W000000VefbrIAB
I noticed this only happens when a specific future job completes approximately ten seconds later than my queuable job. However, occasionally the future job finishes quickly, about the same time my queuable job completes. In this case, my code runs perfectly.
My intuition is this, the future job has locked the record my queuable job is trying to update and, if the future job takes a long time to execute, my queuable job times out before it can gain access to the record.
Is this future job the cause of the issue? If so, what possibilities are there to remedy this?