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
NinoJoseNinoJose 

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.

 

Regards

Pradeep_NavatarPradeep_Navatar

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.

NinoJoseNinoJose

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. :-(

Karthi_VeluKarthi_Velu

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 (https://developer.salesforce.com/blogs/engineering/2012/09/group-membership-operation-already-in-progress-managing-group-membership-locks-for-success.html" target="_blank)
  2. you can activate the granular locking (https://developer.salesforce.com/docs/atlas.en-us.draes.meta/draes/draes_tools_granular_locking.htm" target="_blank)