how to resolve concurrency conflict for bulk create in Rally using REST API using python

424 views Asked by At

I am trying to create >100 items as AllowedAttributeValue using WSAPI in Rally from python without pyral. Input is from a input file. Code -

for line in inputFile:
    body = {<body>}
    try:
        r = requests.post(url, headers=headers, data=body, proxies=proxy)

Not all 100 rows are getting updated. number vary from 40-70. Error :

["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.WorkspaceConfiguration : ObjectID : <objid>"], "Warnings": []}}

Looking for a resolution. Appreciate your help!

1

There are 1 answers

2
Kyle Morse On

I'm not super familiar with the python toolkit, but in general this usually happens when you're bouncing around between app servers and you're firing off requests faster than the cache sync can occur. WSAPI writes are eventually consistent across the system, immediately consistent on the app server node that handled the request. Since all of your creates are modifying the same object (they all reference the same AttributeDefinition) you can get ConcurrencyConflictExceptions.

Is there a way in the python toolkit to enable cookies? That usually works, since the load balancer should pin you to a specific node. It should also be faster, since it won't have to do the auth roundtrip on each request either.