Skip to content

Commit 16407fc

Browse files
authored
making ordered invocations the default (#10201)
1 parent 2c7945e commit 16407fc

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
- Update PowerShell worker 7.4 to [4.0.3219](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3219)
1515
- Ensuring proxies are disabled, with a warning, when running in Flex Consumption.
1616
- Fixed an issue leading to a race when invocation responses returned prior to HTTP requests being sent in proxied scenarios.
17-
- Language worker channels will not be started during placeholder mode if we are in-process (#10161)
17+
- Language worker channels will not be started during placeholder mode if we are in-process (#10161)
18+
- Ordered invocations are now the default (#10201)

src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,17 @@ private void LoadScriptJobHostOptions(IServiceProvider provider)
196196
// and a "new" Channel processor (for proper ordering of messages).
197197
private IInvocationMessageDispatcherFactory GetProcessorFactory()
198198
{
199-
if (_hostingConfigOptions.Value.EnableOrderedInvocationMessages ||
200-
FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagEnableOrderedInvocationmessages, _environment))
199+
// Ordered invocations is the default, but allow explicit disabling
200+
if (!_hostingConfigOptions.Value.EnableOrderedInvocationMessages ||
201+
FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagDisableOrderedInvocationMessages, _environment))
201202
{
202-
_workerChannelLogger.LogDebug($"Using {nameof(OrderedInvocationMessageDispatcherFactory)}.");
203-
return new OrderedInvocationMessageDispatcherFactory(ProcessItem, _workerChannelLogger);
203+
_workerChannelLogger.LogDebug($"Using {nameof(ThreadPoolInvocationProcessorFactory)}.");
204+
return new ThreadPoolInvocationProcessorFactory(_processInbound);
204205
}
205206
else
206207
{
207-
_workerChannelLogger.LogDebug($"Using {nameof(ThreadPoolInvocationProcessorFactory)}.");
208-
return new ThreadPoolInvocationProcessorFactory(_processInbound);
208+
_workerChannelLogger.LogDebug($"Using {nameof(OrderedInvocationMessageDispatcherFactory)}.");
209+
return new OrderedInvocationMessageDispatcherFactory(ProcessItem, _workerChannelLogger);
209210
}
210211
}
211212

src/WebJobs.Script/Config/FunctionsHostingConfigOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ internal bool EnableOrderedInvocationMessages
133133
{
134134
get
135135
{
136-
return GetFeatureAsBooleanOrDefault(ScriptConstants.FeatureFlagEnableOrderedInvocationmessages, false);
136+
return GetFeatureAsBooleanOrDefault(ScriptConstants.FeatureFlagEnableOrderedInvocationmessages, true);
137137
}
138138

139139
set

src/WebJobs.Script/ScriptConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public static class ScriptConstants
137137
public const string FeatureFlagStrictHISModeEnabled = "StrictHISModeEnabled";
138138
public const string FeatureFlagStrictHISModeWarn = "StrictHISModeWarn";
139139
public const string FeatureFlagEnableOrderedInvocationmessages = "EnableOrderedInvocationMessages";
140+
public const string FeatureFlagDisableOrderedInvocationMessages = "DisableOrderedInvocationMessages";
140141
public const string HostingConfigDisableLinuxAppServiceDetailedExecutionEvents = "DisableLinuxExecutionDetails";
141142
public const string HostingConfigDisableLinuxAppServiceExecutionEventLogBackoff = "DisableLinuxLogBackoff";
142143
public const string FeatureFlagEnableLegacyDurableVersionCheck = "EnableLegacyDurableVersionCheck";

test/WebJobs.Script.Tests/Configuration/FunctionsHostingConfigOptionsTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public void Property_Validation()
107107
// Supports True/False/1/0
108108
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=True", true),
109109
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=1", true),
110-
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=unparseable", false), // default
111-
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), string.Empty, false), // default
110+
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=unparseable", true), // default
111+
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), string.Empty, true), // default
112112

113113
(nameof(FunctionsHostingConfigOptions.FunctionsWorkerDynamicConcurrencyEnabled), "FUNCTIONS_WORKER_DYNAMIC_CONCURRENCY_ENABLED=1", true),
114114
(nameof(FunctionsHostingConfigOptions.MaximumBundleV3Version), "FunctionRuntimeV4MaxBundleV3Version=teststring", "teststring"),

test/WebJobs.Script.Tests/Workers/Rpc/GrpcWorkerChannelTests.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,12 +1426,34 @@ public async Task Ensure_SuccessfulForwardingAsync_Is_Invoked_OnlyFor_HttpInvoca
14261426
}
14271427

14281428
[Fact]
1429-
public async Task Log_And_InvocationResult_OrderedCorrectly()
1429+
public async Task DispatcherFactory_DefaultsToOrdered()
1430+
{
1431+
await CreateDefaultWorkerChannel();
1432+
var invocationFactoryMessage = _logger.GetLogMessages().Select(m => m.FormattedMessage).Single(m => m.Contains("Factory"));
1433+
Assert.Contains("OrderedInvocationMessageDispatcherFactory", invocationFactoryMessage);
1434+
}
1435+
1436+
[Fact]
1437+
public async Task DispatcherFactory_CanBeOverridden_WithAppSetting()
1438+
{
1439+
_testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsFeatureFlags, ScriptConstants.FeatureFlagDisableOrderedInvocationMessages);
1440+
await CreateDefaultWorkerChannel();
1441+
var invocationFactoryMessage = _logger.GetLogMessages().Select(m => m.FormattedMessage).Single(m => m.Contains("Factory"));
1442+
Assert.Contains("ThreadPoolInvocationProcessorFactory", invocationFactoryMessage);
1443+
}
1444+
1445+
[Fact]
1446+
public async Task DispatcherFactory_CanBeOverridden_WithHostingConfig()
14301447
{
1431-
// Without this feature flag, this test fails every time on multi-core machines as the logs will
1432-
// be processed out-of-order
1433-
_testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsFeatureFlags, ScriptConstants.FeatureFlagEnableOrderedInvocationmessages);
1448+
_hostingConfigOptions.Value.EnableOrderedInvocationMessages = false;
1449+
await CreateDefaultWorkerChannel();
1450+
var invocationFactoryMessage = _logger.GetLogMessages().Select(m => m.FormattedMessage).Single(m => m.Contains("Factory"));
1451+
Assert.Contains("ThreadPoolInvocationProcessorFactory", invocationFactoryMessage);
1452+
}
14341453

1454+
[Fact]
1455+
public async Task Log_And_InvocationResult_OrderedCorrectly()
1456+
{
14351457
await CreateDefaultWorkerChannel();
14361458
_metricsLogger.ClearCollections();
14371459

0 commit comments

Comments
 (0)