function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

UNKNOWN_EXCEPTION, group membership operation already in progress

Hi All,


I have an future method that inserts/updates user. However during checking on Setup->Monitoring->Apex Jobs I found out that there are some instances that I get the an error 'First error: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, group membership operation already in progress:'


I'm not sure about the error since it was not meaningful to me. Can somebody shed some light regarding this issue? I have tried search for other thread but none to avail.




In my opinion, this error comes when either you create a group or add a group member through trigger and you trigger works on user after insert. It seems that you are trying to update a field after inserting the user.


Thanks Pradeep. However, the I'm not updating a user rather creating a new user. A have a trigger on Contact Trigger that creates Partner User upon some validation. I can't seem to replicate this issue as it was intermitent. :-(


The reason might the same record trying to update in the same request context. I had same problem during the contact merge while updating the record before doing the Merge.

Reda BenhemmoucheReda Benhemmouche
It happends when complex sharing calculations is processing.
During the sharing calculation a lock is taken to ensure data integrity, so some administrative operation are not available (change user role, create/move/delete a role or a territory, ... ).
2 solutions: 
  1. You can implement a retry strategy to fix your issue. See the detailed article (" target="_blank)
  2. you can activate the granular locking (" target="_blank)