4

I'm currently working on an enterprise portal built completely using provider hosted apps, ECMA CSOM and .NET client object model. We are almost at the end of our development phase and we started seeing many weird issues when more and more people started using/testing the portal.

When we investigated all the issues we end up finding that these issues were caused because of multiple calls trying to access a particular item/document/list simultaneously. I'll provide some classic scenarios that happened in our application.

  1. We have a provider hosted app which user uses to update a document in a document library. When two users simultaneously tried to update a same document one of the calls failed because there will be a save .

enter image description here

  1. There is a list which contains population of all countries. Once we get population data of more countries we have to insert that in the list. While inserting the population value, we will check if the country item is already there. If yes, update the population value. Else, create a new item for that country.

But when two calls simultaneously try to add a country value which is not in the list it ends up creating duplicates since the both the calls check the list at the same time and assume there is no item for this country.

enter image description here

How can we handle concurrency in above cases? Any insights provided would be of great help.

  • Just a thought on number 2. Set the field as Enforce unique values, one of the calls will have an error for it existing, in the error handling do some other stuff if necessary. Like update the item or tell the user – Anders Aune Oct 9 '15 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.