Race Condition Issue

Hello Celigo Community,

I am experiencing a race condition issue in my integration flows that involve Salesforce Account and Address records. When an Address record is saved, it simultaneously triggers an update on the associated Account record. Both real-time flows, for Account and Address records, execute an HTTP patch to update the same "Customer" record in Business Central. Due to the simultaneous execution of these two flows, I am encountering a race condition where one of the flows returns an error stating that the record has already been saved.

I have tried adjusting concurrency settings, but the issue persists. I would like to ask the community for any suggestions or best practices in handling such race conditions. Specifically, I am looking for a way to delay the trigger of the Account record when an Address record is saved, or any alternative approach that can help maintain data integrity while avoiding race conditions. I know this community has been asking for a delay function, but it's not yet available.

So, I am asking:

If you have encountered a similar issue or have any insights on resolving this problem, your input would be greatly appreciated. I am open to exploring different solutions to ensure the smooth functioning of our integration flows.

Thanks for your help!

0

Comments

6 comments
Date Votes
  • Are you positive that both the flows are using the exact same connection record, and can you confirm that you set the concurrency level on the connection to 1?  This should solve the issue, because concurrency level 1 means that only a single update will happen at a time.

    0
  • Thank you for your response Scott! I can confirm that both real-time flows are using the same connection record, "Dynamics 365 BC - with concurrency set to one", and the concurrency level is indeed set to 1. Despite this configuration, I am still encountering the race condition issue.

    I understand that setting the concurrency level to 1 should ideally resolve the problem by allowing only a single update to happen at a time. However, it seems that this solution is not working as expected in my case.



    0
  • Strange. From the Celigo side, if concurrency level is set to 1, then we will only send 1 single request at a time.

    I am not familiar with business central, but i wonder if there are any triggers or script type things happening on the business central side that could be causing this. Another idea I will try to flush out internally is if we can prevent the Account triggering in Salesforce when only the address is changed. This is all dependent on what Salesforce allows though. I will report back if I learn anything helpful.

    0
  • We've put some logic in Salesforce to stop the account from being triggered when only the address is modified. This seems to have taken care of the issue with the account and address running at the same time. 

    As for the Business Central aspect, I'm going to look into it further to see if it's contributing to the problem in any way. 

    0
  • Hi Nuri Ensing
         Here are a couple of solutions for your issue.
    1. Reg: concurrency 
        As both flows are running parallel, and if we set concurrency 1, we request to Microsoft only one request at a time.
    why do you get an error? It's because, as you are trying to fetch Etag from BC to set it in headers., we request to BC one by one and Etag is getting modified after the first request for a customer record we are trying to set the same tag for addresses for a customer record, and it's already changed, that's the reason it will throw an error from BusinessCentral as "record has already been saved".
    Resolution: One way we need to set headers as * instead of exact Etag, as we use concurrency 1., it's fine to use it.
    2. Yes As you did it., we need to stop updating parent records i.e., Account when we are updating the Address record (related list), through the custom trigger/filters for account export we can achieve it to pick only specific record.

    3. Instead of two flows you can have a single flow., As the address record is updated parent record is modified.
    you can create a Salesforce listener for Account Export and you can include the related list as "address" and you can fetch both at a time from the same export.

    1
  • I see I did not respond to your answer Muneswara Thotakura. Although some time has passed, I wanted to let you know that the ETag solution worked perfectly.

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post