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
RamanaRamana 

I send 200 object in upsert but get back 100 objects in upsertresult

HI All,

 

I am seeing a weired issue with upsert...!

 

 

I have a program with multiple threads trying to upsert(). Each thread sends 200 objects using upsert().

 

And many of them get back only 100 objects in upsertResult[]. Very of them get back 200 objects.

 

Please advice what could be happening here.

 

Thanks in advance.

 

Regards,

Ramana Maddikunta 

Best Answer chosen by Admin (Salesforce Developers) 
RamanaRamana

How stupid I am!!!

 

Simon, sorry for wasting your time. But may be my tiered eyes overlooked a line of code that I removed from the tailored piece of code I sent you (highlighted in RED below). And the default value for ErrorThreshold is 100. May be I need some rest now..!! It had been a long day about 19-20 hours..!! huh!

 

int objIndex = 0;

int successIndex = 0;

int errorIndex = 0;

 

UpsertResult[] upsertRes = m_binding.upsert(externalIDFieldName, sfdcObjectArray);

System.out.println("UpsertResult size " + upsertRes.length);

for (UpsertResult result : upsertRes)

{

objIndex++;

if (result.isSuccess())

{

successIndex++;

System.out.println("Object upserted successfully);

}

else

{

errorIndex++;

String errorMessage = result.getErrors(0).getMessage();

System.out.println("Error corresponding to the object " + errorIndex + "::"+ errorMessage);

 

if(errorIndex > ErrorThreshold) break;

 

}

}

System.out.println( "Executed Batch upload for (" + successIndex + "+" + errorIndex + ")" + (successIndex + errorIndex) + " records");

 

 

 

Message Edited by Ramana on 04-27-2009 09:33 PM

All Answers

SuperfellSuperfell
Can you provide a wire capture that shows this? each thread in your client has its own stub instance, yes ?
RamanaRamana

Simon,

 

Thanks for the quick response. No, I am using the same stub for all the threads.

 

Regards,

Ramana Maddikunta 

SuperfellSuperfell
recipe for disaster, I've haven't seen a soap toolkit yet that has threadsafe stubs that support concurrent requests on a single instance.
RamanaRamana

Simon,

 

Thanks a lot for the quick advice. I will make appropriate changes and see if that does the trick.

 

 

Regards,

Ramana Maddikunta 

RamanaRamana

Simon,

 

 Through I made every thread use its own stub instance, the same issue persists.

 

Please advice what else could be going on.

 

 

Regards,

Ramana Maddikunta 

SuperfellSuperfell
Please post some code and ideally a capture of the soap request/response that demonstrates the problem.
RamanaRamana
Simon,
 
Here is the piece of code, I am using. Here sfdcObjectArray has 200 objects. I am not sure how do I get the soap request/response messages, so I can not provide at this point.
 
int objIndex = 0;
int successIndex = 0;
int errorIndex = 0;

UpsertResult[] upsertRes = m_binding.upsert(externalIDFieldName, sfdcObjectArray);
System.out.println("UpsertResult size " + upsertRes.length);
for (UpsertResult result : upsertRes)
{
objIndex++;
if (result.isSuccess())
{
successIndex++;
System.out.println("Object upserted successfully);
}
else
{
errorIndex++;
String errorMessage = result.getErrors(0).getMessage();
System.out.println("Error corresponding to the object " + errorIndex + "::"+ errorMessage);
}
}
System.out.println( "Executed Batch upload for (" + successIndex + "+" + errorIndex + ")" + (successIndex + errorIndex) + " records");
 
 
Regards,
Ramana Maddikunta 
SuperfellSuperfell
Where does sfdcObjectArray come from? are you sure no other thread is potentially changing it? can you dump its length before and after the upsert call.
SuperfellSuperfell
If you run single threaded do you still see the problem ?
RamanaRamana

Simon,

 

Each thread has its own instance of sfdcObjectArray, so NO chance of overstepping. The size of the sfdcObjectArray before the call is 200 in each of them. And interestingly, the usertResult size immediately after the upsert call is 200, but when I iterate through the upsertResult array, then the last statement in my code sample, gives 100 records..!!

 

Not sure if for each is the spoilter here. 

 

Regards,

Ramana Maddikunta 

Message Edited by Ramana on 04-27-2009 09:11 PM
RamanaRamana

Yes Simon,

 

I run into the same problem, even with a single thread.

 

Thanks,

Ramana Maddikunta 

RamanaRamana

How stupid I am!!!

 

Simon, sorry for wasting your time. But may be my tiered eyes overlooked a line of code that I removed from the tailored piece of code I sent you (highlighted in RED below). And the default value for ErrorThreshold is 100. May be I need some rest now..!! It had been a long day about 19-20 hours..!! huh!

 

int objIndex = 0;

int successIndex = 0;

int errorIndex = 0;

 

UpsertResult[] upsertRes = m_binding.upsert(externalIDFieldName, sfdcObjectArray);

System.out.println("UpsertResult size " + upsertRes.length);

for (UpsertResult result : upsertRes)

{

objIndex++;

if (result.isSuccess())

{

successIndex++;

System.out.println("Object upserted successfully);

}

else

{

errorIndex++;

String errorMessage = result.getErrors(0).getMessage();

System.out.println("Error corresponding to the object " + errorIndex + "::"+ errorMessage);

 

if(errorIndex > ErrorThreshold) break;

 

}

}

System.out.println( "Executed Batch upload for (" + successIndex + "+" + errorIndex + ")" + (successIndex + errorIndex) + " records");

 

 

 

Message Edited by Ramana on 04-27-2009 09:33 PM
This was selected as the best answer