Created attachment 13522 [details] a possible solution If there is conflict resolution on a foreignSecurityPrincipal that can cause a unique index constraint on objectSID, as both the original and conflict object exist at the same time. Deleting the conflict object doesn't help, as the deleted object is still in the index.
Created attachment 13826 [details] patch for master by Gary
Fixed as 704bbae25c07c08c051a66ae0a83fb5abda373f1 for 4.8.0