Rally - WSAPI: Concurrency error when using WSAPI
search cancel

Rally - WSAPI: Concurrency error when using WSAPI

book

Article ID: 77114

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

When writing integrations that perform numerous simultaneous transactions or many transactions in rapid succession, a transaction may fail with a concurrency exception.  These errors may be seen even though the HTTP status code is 200 (the status of 200 just means at the protocol level everything went fine passing the information back and forth, but our application may not have liked something - which will be returned in the errors section). 

The error returned may appear as follows:

"Concurrency conflict: [Object has been modified since being read for update in this context] - ConcurrencyConflictException : Modified since read on update : Object Class : com.f4tech.slm.domain.Subscription : ObjectID : 100000001"

or it may appear as the following

"Could not update: Could not write changes in Unit Of Work"

 

Cause

This issue is frequently seen in multi-threaded applications where the external application is sending multiple update requests at the same time.

This is not an issue with the newly created or modified object being updated, but usually more related to synchronization of data between application servers in our cluster.  Editing the same object at the same time can cause this, as could revising a two objects that performs a cascade update to the same parent/child.

Resolution

This can be mitigated by the following suggestions:

  • Having the app work in a single-threaded mode thereby sending requests one at a time with a slight delay.
  • Capturing the cookie from a response and reusing that in future requests.  The JSESSIONID attribute contains a server ID and will cause subsequent requests to prefer that server which keeps server caches warmed up more effectively for your queries.
  • Trap/detect the error and retry the request again.