Set_entry endpoint is not able to handle large number of cases

Currently, I am debugging an issue where I am calling set_relationship() endpoint with relation between account an cases .
But one code it is throwing “NusoapSoap->shutdown: service died unexpectedly” error because there are around 300k undeleted cases mapped to that account id.

As per my investigation this while is the culprit.
Other configuration related parameters are already in place like memory_limit ,post_max_size , upload_max_filesize
I am thinking this is buggy code in there because at some point of time it will break if records are too many and memory is not able to hold those huge data.

Please provide some guidance on it.

300k related records is a lot, if you can clean up your database it will be better.

Also consider if the problem is the database timing out, in which case you can try improving the indexes.

But assuming you know all that, and your company is actually huge and all that data really needs to be there, I guess you could try improving the code on that loop.

If you check here

You’ll see there are other function to get related stuff, using pagination, so that smaller chunks of data can be processed at a time. I’m not sure this would solve anything but it’s worth a try. It will still take a loooong time to finish; but maybe it won’t break.

Hello Rajesh,

300k Cases for 1 Account?

Before looking into the code, look into the data architecture here?
What did you use cases for?
Do they all have to be always present in the cases module or can you archive old ones?
Scaling (any CRM / system) can be quite difficult and very specific to your case.
What works great with 30 records, might completely break with 300k.

And even better:
Look into the non technical requirements, talk to the non technical stake holders.
They probably should know, that the system is (maybe) quite big and will require different approaches now.

And just out of curiosity: If you’ve got 300k cases for 1 account, how many records do you hold in your whole DB?