An update conflict has occurred, and you must re-try this action. The object SPFarm Name=

Feb 17, 2010 at 7:39 AM

Hi,

I'm using ServiceLocator pattern and classes. When register interfaces + classes to SPFarm property bags using SPG API, I do get this exception:

An update conflict has occurred, and you must re-try this action. The object SPFarm-2b89-4f2e-a928-b52bb8774e3b is being updated by NT AUTHORITY\NETWORK SERVICE, in the w3wp process, on machine OVIDIUBECHES.  View the tracing log for more information about the conflict.   at Microsoft.SharePoint.Administration.SPConfigurationDatabase.StoreObject(SPPersistedObject obj, Boolean storeClassIfNecessary, Boolean ensure)
   at Microsoft.SharePoint.Administration.SPConfigurationDatabase.PutObject(SPPersistedObject obj, Boolean ensure)
   at Microsoft.SharePoint.Administration.SPPersistedObject.Update()
   at Microsoft.SharePoint.Administration.SPFarm.Update()
   at Microsoft.SharePoint.Administration.SPPersistedObject.Update(Boolean ensure)
   at Microsoft.Practices.SPG.Common.Configuration.SPFarmPropertyBag.Update()
   at Microsoft.Practices.SPG.Common.Configuration.HierarchicalConfig.SetInPropertyBag(String key, Object value, IPropertyBag propertyBag)

The problem is that is not happends all the time. Some time all I do is a refresh and then try to activate again the site collection feature which register interfaces + classes. The code is running with elevated privileges.  Also, I've noticed this is not an isolated case. I have other 5 MOSS servers (devel / production) when from time to time I get that exception. Is there a workaround for it ? I did found this: http://support.microsoft.com/kb/939308 but is not a permanent fix. Is working in the next moment after doings the steps from kb.

Many thanks,

Ovidiu Beches-Puia

Feb 18, 2010 at 3:53 PM

Hi Ovidiu,

Sorry for the delayed response.  This is an issue you will see if the property bag is modified elsewhere while you are updating, and is a potential condition any time you update.  We are updating in the next release our mechanism to save the settings to better handle this situation.  We didn't feel like we should do this at the lower level configuration manager however since there may be different ways that customers want to address this situation when it occurs.  For this release, I'd recommend addressing this by retrying a few times if this condition is encountered, similar to the following:

 

           for (int retryCnt = 0; retryCnt < MaxConfigurationSaveRetryCount && !savedConfig; retryCnt++)
            {
                // if multiple writes occur concurrently to the property bag for an object at the same time, SharePoint will throw.
                // catch that exception and retry saving the configuration a few times before giving up.
                try
                {
                    serviceLocationConfig.RegisterTypeMapping<IFoo, Foo>();
                    savedConfig = true;
                }
                catch (SPUpdatedConcurrencyException ex)
                {
                    savedException = ex;        
                }
            }

            if (savedConfig == false)
            {
                throw savedException;
            }