I have enabled Disalbe Parallel Apex Testing to solve UNABLE_TO_LOCK_ROW errors. Let test methods run fast, then I add the isParallel
annotation to existing test classes. But that can still cause UNABLE_TO_LOCK_ROW errors event thought each test classes create test data isolate.
I checked the errors which mostly the following one:
System.DmlException: Insert failed.
First exception on row 0;
first error: UNABLE_TO_LOCK_ROW,
unable to obtain exclusive access to this record: []
Looking back to my code that causes the error by creating a new lead record.
My question is why does create a new lead record that can still lock the database? Is there another solution except removing the isParallel
annotation from the error test class?