Need help to setup retry policy in .net mvc 4.6.1

Vote:
 

Recently we are facing a lot of connection timeout issues with our application. So i want to use retry policy while connecting to commercemanager from my application. Can someone help with an example on how to leverage episerver SqlTransientErrorsRetryPolicy if i can. I hope its possible.

So far i've tried setting up below configurations in web.config.

Inside configurations>configsections 

<section name="episerver.dataStore" type="EPiServer.Data.Configuration.EPiServerDataStoreSection, EPiServer.Framework.AspNet" />

At the bottom inside configurations>

<episerver.dataStore>
    <dataSettings connectionStringName="EcfSqlConnection" retries="2" />
  </episerver.dataStore>.

Here, EcfSqlConnection is my commercemanager connection string.

This gives me an issue launching api project.. Not sure if i'm heading in the right direction. Is there any seperate code change required as well.

Any help will be appreciated.

#272210
Edited, Feb 15, 2022 8:52
Vote:
 

Yes if you are calling database queries directly you need to use the RetryPolicy explicitly. However retry policy is just hiding the problem (just enough to make it goes away). I strongly suggest to look into those "timeout issues" to figure out the root cause and fix it

#272221
Feb 15, 2022 12:56
Dhanush - Feb 17, 2022 8:16
Yes, we need to avoid having unexpected issues. Thats why need this change while we figure the rootcause. So if I'm using methods like cart.acceptchanges() i dont need to explicitely in the code and only config change is enough?
Quan Mai - Feb 17, 2022 8:55
If memory serves then yes, it calls to lower level database access which has retry policy applied
Dhanush - Feb 28, 2022 21:35
I read your blog 'understand retry policies'. I don't see it working for some reason. In my app, do I need to have 2 datasettings, as in the next comment?
Maybe this is silly, but i'm getting issue saying that 2 data settings are not allowed. Can you tell me whats wrong here? Also when i keep only commercedb i get screen asking me to update schema, but when i use cms db it doesn't throw any error.
Vote:
 

<episerver.dataStore>

<dataSettings connectionStringName="cms db" retries="2" />

<dataSettings connectionStringName="commerce DB" retries="2" />

<episerver.dataStore>

#275024
Feb 28, 2022 21:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.