I had a trigger that fired from webhook, this trigger receive JSON that contain external Id for account object, inside the trigger I do an upsert on account object using the following code
Database.upsert(accountrecord, external_id__c)
but sometimes for unknown reason I got the following exception
System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: External_Id__c duplicates value on record with id: 0011x00000Gc4LI: []
I tried to add SOQL query to retrieve the account record with the external Id I have to testing purpose and I didn't get any records!
New Update:
I think it's related to this known issue, they said that it solved in Summer 18, but I'm still facing this issue.