diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3a383a..bb4418b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,11 @@
# Changelog
-## v1.1.2
+## Unreleased
### New
-* Support configurable backoff intervals ([#163](https://github.com/microsoft/durabletask-mssql/pull/163)) - contributed by [@tompostler](https://github.com/tompostler)
+* Support configurable max backoff intervals ([#163](https://github.com/microsoft/durabletask-mssql/pull/163)) - contributed by [@tompostler](https://github.com/tompostler)
+* Support configurable min and delta backoff intervals ([#174](https://github.com/microsoft/durabletask-mssql/pull/174)) - contributed by [@dmetzgar](https://github.com/dmetzgar)
### Updates
diff --git a/src/DurableTask.SqlServer/BackoffPollingHelper.cs b/src/DurableTask.SqlServer/BackoffPollingHelper.cs
index c904c58..147abe1 100644
--- a/src/DurableTask.SqlServer/BackoffPollingHelper.cs
+++ b/src/DurableTask.SqlServer/BackoffPollingHelper.cs
@@ -15,9 +15,9 @@ class BackoffPollingHelper
readonly RandomizedExponentialBackoffStrategy backoffStrategy;
readonly AsyncAutoResetEvent resetEvent;
- public BackoffPollingHelper(TimeSpan minimumInterval, TimeSpan maximumInterval)
+ public BackoffPollingHelper(TimeSpan minimumInterval, TimeSpan maximumInterval, TimeSpan deltaBackoff)
{
- this.backoffStrategy = new RandomizedExponentialBackoffStrategy(minimumInterval, maximumInterval);
+ this.backoffStrategy = new RandomizedExponentialBackoffStrategy(minimumInterval, maximumInterval, deltaBackoff);
this.resetEvent = new AsyncAutoResetEvent(signaled: false);
}
@@ -46,11 +46,6 @@ class RandomizedExponentialBackoffStrategy
uint backoffExponent;
- public RandomizedExponentialBackoffStrategy(TimeSpan minimumInterval, TimeSpan maximumInterval)
- : this(minimumInterval, maximumInterval, minimumInterval)
- {
- }
-
public RandomizedExponentialBackoffStrategy(
TimeSpan minimumInterval,
TimeSpan maximumInterval,
diff --git a/src/DurableTask.SqlServer/SqlOrchestrationService.cs b/src/DurableTask.SqlServer/SqlOrchestrationService.cs
index 8923765..4e755cd 100644
--- a/src/DurableTask.SqlServer/SqlOrchestrationService.cs
+++ b/src/DurableTask.SqlServer/SqlOrchestrationService.cs
@@ -35,8 +35,14 @@ public class SqlOrchestrationService : OrchestrationServiceBase
public SqlOrchestrationService(SqlOrchestrationServiceSettings? settings)
{
this.settings = ValidateSettings(settings) ?? throw new ArgumentNullException(nameof(settings));
- this.orchestrationBackoffHelper = new BackoffPollingHelper(TimeSpan.FromMilliseconds(50), this.settings.MaxOrchestrationPollingInterval);
- this.activityBackoffHelper = new BackoffPollingHelper(TimeSpan.FromMilliseconds(50), this.settings.MaxActivityPollingInterval);
+ this.orchestrationBackoffHelper = new BackoffPollingHelper(
+ this.settings.MinOrchestrationPollingInterval,
+ this.settings.MaxOrchestrationPollingInterval,
+ this.settings.DeltaBackoffOrchestrationPollingInterval);
+ this.activityBackoffHelper = new BackoffPollingHelper(
+ this.settings.MinActivityPollingInterval,
+ this.settings.MaxActivityPollingInterval,
+ this.settings.DeltaBackoffActivityPollingInterval);
this.traceHelper = new LogHelper(this.settings.LoggerFactory.CreateLogger("DurableTask.SqlServer"));
this.dbManager = new SqlDbManager(this.settings, this.traceHelper);
this.lockedByValue = $"{this.settings.AppName},{Process.GetCurrentProcess().Id}";
diff --git a/src/DurableTask.SqlServer/SqlOrchestrationServiceSettings.cs b/src/DurableTask.SqlServer/SqlOrchestrationServiceSettings.cs
index 14b5a07..048a723 100644
--- a/src/DurableTask.SqlServer/SqlOrchestrationServiceSettings.cs
+++ b/src/DurableTask.SqlServer/SqlOrchestrationServiceSettings.cs
@@ -93,6 +93,14 @@ public SqlOrchestrationServiceSettings(string connectionString, string? taskHubN
[JsonProperty("maxActiveOrchestrations")]
public int MaxActiveOrchestrations { get; set; } = Environment.ProcessorCount;
+ ///
+ /// Gets or sets the minimum interval to poll for orchestrations.
+ /// Polling interval increases when no orchestrations or activities are found.
+ /// The default value is 50 milliseconds.
+ ///
+ [JsonProperty("minOrchestrationPollingInterval")]
+ public TimeSpan MinOrchestrationPollingInterval { get; set; } = TimeSpan.FromMilliseconds(50);
+
///
/// Gets or sets the maximum interval to poll for orchestrations.
/// Polling interval increases when no orchestrations or activities are found.
@@ -101,6 +109,22 @@ public SqlOrchestrationServiceSettings(string connectionString, string? taskHubN
[JsonProperty("maxOrchestrationPollingInterval")]
public TimeSpan MaxOrchestrationPollingInterval { get; set; } = TimeSpan.FromSeconds(3);
+ ///
+ /// Gets or sets the delta backoff interval to poll for orchestrations.
+ /// Polling interval increases by this delta when no orchestrations are found.
+ /// The default value is 50 milliseconds.
+ ///
+ [JsonProperty("deltaBackoffOrchestrationPollingInterval")]
+ public TimeSpan DeltaBackoffOrchestrationPollingInterval { get; set; } = TimeSpan.FromMilliseconds(50);
+
+ ///
+ /// Gets or sets the minimum interval to poll for activities.
+ /// Polling interval increases when no activities are found.
+ /// The default value is 50 milliseconds.
+ ///
+ [JsonProperty("minActivityPollingInterval")]
+ public TimeSpan MinActivityPollingInterval { get; set; } = TimeSpan.FromMilliseconds(50);
+
///
/// Gets or sets the maximum interval to poll for activities.
/// Polling interval increases when no activities are found.
@@ -109,6 +133,14 @@ public SqlOrchestrationServiceSettings(string connectionString, string? taskHubN
[JsonProperty("maxActivityPollingInterval")]
public TimeSpan MaxActivityPollingInterval { get; set; } = TimeSpan.FromSeconds(3);
+ ///
+ /// Gets or sets the delta backoff interval to poll for activities.
+ /// Polling interval increases by this delta when no activities are found.
+ /// The default value is 50 milliseconds.
+ ///
+ [JsonProperty("deltaBackoffActivityPollingInterval")]
+ public TimeSpan DeltaBackoffActivityPollingInterval { get; set; } = TimeSpan.FromMilliseconds(50);
+
///
/// Gets or sets a flag indicating whether the database should be automatically created if it does not exist.
///