Skip to content

Commit

Permalink
feature: WIP - Session Consistency Retries
Browse files Browse the repository at this point in the history
  • Loading branch information
dibahlfi committed Jan 22, 2025
1 parent 6b2e0b4 commit f855753
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ internal sealed class SessionTokenMismatchRetryPolicy : IRetryPolicy
private const int defaultMaximumBackoffTimeInMilliseconds = 500;
private const int backoffMultiplier = 5; // before it was very aggressive
private readonly ISessionRetryOptions sessionRetryOptions;

private const int DEFAULT_MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED = 1; // added by Abhijeet
internal const int MIN_MIN_IN_REGION_RETRY_TIME_FOR_WRITES_MS = 100; // added by fabien - have a question on this and DEFAULT_MIN_IN_REGION_RETRY_TIME_FOR_WRITES_MS
private const int DEFAULT_MIN_IN_REGION_RETRY_TIME_FOR_WRITES_MS = 500; // added by fabien
internal const int MIN_MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED = 1; // added by Fabine, same as by Abhijeet above
private readonly DateTimeOffset startTime = DateTime.UtcNow;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void SessionRetryOptionsDefaultValuesTest()
},
};


Assert.IsTrue(clientOptions.SessionRetryOptions.MinInRegionRetryTime == ConfigurationManager.GetMinRetryTimeInLocalRegionWhenRemoteRegionPreferred());
Assert.IsTrue(clientOptions.SessionRetryOptions.MaxInRegionRetryCount == ConfigurationManager.GetMaxRetriesInLocalRegionWhenRemoteRegionPreferred());

Expand Down Expand Up @@ -122,7 +123,7 @@ public async Task ReadOperationWithReadSessionUnavailableTest(FaultInjectionOper
int sessionTokenMismatchRetryAttempts , Boolean remoteRegionPreferred)
{
string[] preferredRegions = this.writeRegionMap.Keys.ToArray();
// if I go to South Central US for reading an item, I should get a 404/2002 response for 90 minutes
// if I go to first region for reading an item, I should get a 404/2002 response for 10 minutes
FaultInjectionRule badSessionTokenRule = new FaultInjectionRuleBuilder(
id: "badSessionTokenRule",
condition:
Expand Down Expand Up @@ -185,7 +186,6 @@ public async Task ReadOperationWithReadSessionUnavailableTest(FaultInjectionOper
// Check if the SessionTokenMismatchRetryPolicy retries on the bad / lagging region
// for sessionTokenMismatchRetryAttempts by tracking the badSessionTokenRule hit count
long hitCount = badSessionTokenRule.GetHitCount();
Console.WriteLine($" hit count is {hitCount}");

if (remoteRegionPreferred)
{
Expand All @@ -212,8 +212,7 @@ public async Task WriteOperationWithReadSessionUnavailableTest(FaultInjectionOpe
{

string[] preferredRegions = this.writeRegionMap.Keys.ToArray();
//Console.WriteLine($" preferred regions are {String.Join(" , ", preferredRegions)}");
// if I go to South Central US for reading an item, I should get a 404/2002 response for 90 minutes

FaultInjectionRule badSessionTokenRule = new FaultInjectionRuleBuilder(
id: "badSessionTokenRule",
condition:
Expand Down Expand Up @@ -270,8 +269,6 @@ public async Task WriteOperationWithReadSessionUnavailableTest(FaultInjectionOpe
// Check if the SessionTokenMismatchRetryPolicy retries on the bad / lagging region
// for sessionTokenMismatchRetryAttempts by tracking the badSessionTokenRule hit count
long hitCount = badSessionTokenRule.GetHitCount();
Console.WriteLine($" hit count is {hitCount}");

if (remoteRegionPreferred)
{
// higher hit count is possible while in MinRetryWaitTimeWithinRegion
Expand Down

0 comments on commit f855753

Please sign in to comment.