Skip to content

Commit

Permalink
making ordered invocations the default (#10201) (#10207)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettsam authored Jun 4, 2024
1 parent c84a0fe commit 4685e06
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
3 changes: 2 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
- Update PowerShell worker 7.4 to [4.0.3219](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3219)
- Update Azure.Identity to 1.11.0 (#10002)
- Fixed an issue leading to a race when invocation responses returned prior to HTTP requests being sent in proxied scenarios.
- Language worker channels will not be started during placeholder mode if we are in-process (#10162)
- Language worker channels will not be started during placeholder mode if we are in-process (#10161)
- Ordered invocations are now the default (#10201)
13 changes: 7 additions & 6 deletions src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,17 @@ private void LoadScriptJobHostOptions(IServiceProvider provider)
// and a "new" Channel processor (for proper ordering of messages).
private IInvocationMessageDispatcherFactory GetProcessorFactory()
{
if (_hostingConfigOptions.Value.EnableOrderedInvocationMessages ||
FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagEnableOrderedInvocationmessages, _environment))
// Ordered invocations is the default, but allow explicit disabling
if (!_hostingConfigOptions.Value.EnableOrderedInvocationMessages ||
FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagDisableOrderedInvocationMessages, _environment))
{
_workerChannelLogger.LogDebug($"Using {nameof(OrderedInvocationMessageDispatcherFactory)}.");
return new OrderedInvocationMessageDispatcherFactory(ProcessItem, _workerChannelLogger);
_workerChannelLogger.LogDebug($"Using {nameof(ThreadPoolInvocationProcessorFactory)}.");
return new ThreadPoolInvocationProcessorFactory(_processInbound);
}
else
{
_workerChannelLogger.LogDebug($"Using {nameof(ThreadPoolInvocationProcessorFactory)}.");
return new ThreadPoolInvocationProcessorFactory(_processInbound);
_workerChannelLogger.LogDebug($"Using {nameof(OrderedInvocationMessageDispatcherFactory)}.");
return new OrderedInvocationMessageDispatcherFactory(ProcessItem, _workerChannelLogger);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/WebJobs.Script/Config/FunctionsHostingConfigOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal bool EnableOrderedInvocationMessages
{
get
{
return GetFeatureAsBooleanOrDefault(ScriptConstants.FeatureFlagEnableOrderedInvocationmessages, false);
return GetFeatureAsBooleanOrDefault(ScriptConstants.FeatureFlagEnableOrderedInvocationmessages, true);
}

set
Expand Down
1 change: 1 addition & 0 deletions src/WebJobs.Script/ScriptConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public static class ScriptConstants
public const string FeatureFlagStrictHISModeEnabled = "StrictHISModeEnabled";
public const string FeatureFlagStrictHISModeWarn = "StrictHISModeWarn";
public const string FeatureFlagEnableOrderedInvocationmessages = "EnableOrderedInvocationMessages";
public const string FeatureFlagDisableOrderedInvocationMessages = "DisableOrderedInvocationMessages";
public const string HostingConfigDisableLinuxAppServiceDetailedExecutionEvents = "DisableLinuxExecutionDetails";
public const string HostingConfigDisableLinuxAppServiceExecutionEventLogBackoff = "DisableLinuxLogBackoff";
public const string FeatureFlagEnableLegacyDurableVersionCheck = "EnableLegacyDurableVersionCheck";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public void Property_Validation()
// Supports True/False/1/0
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=True", true),
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=1", true),
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=unparseable", false), // default
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), string.Empty, false), // default
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), "EnableOrderedInvocationMessages=unparseable", true), // default
(nameof(FunctionsHostingConfigOptions.EnableOrderedInvocationMessages), string.Empty, true), // default

(nameof(FunctionsHostingConfigOptions.FunctionsWorkerDynamicConcurrencyEnabled), "FUNCTIONS_WORKER_DYNAMIC_CONCURRENCY_ENABLED=1", true),
(nameof(FunctionsHostingConfigOptions.MaximumBundleV3Version), "FunctionRuntimeV4MaxBundleV3Version=teststring", "teststring"),
Expand Down
30 changes: 26 additions & 4 deletions test/WebJobs.Script.Tests/Workers/Rpc/GrpcWorkerChannelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,12 +1426,34 @@ public async Task Ensure_SuccessfulForwardingAsync_Is_Invoked_OnlyFor_HttpInvoca
}

[Fact]
public async Task Log_And_InvocationResult_OrderedCorrectly()
public async Task DispatcherFactory_DefaultsToOrdered()
{
await CreateDefaultWorkerChannel();
var invocationFactoryMessage = _logger.GetLogMessages().Select(m => m.FormattedMessage).Single(m => m.Contains("Factory"));
Assert.Contains("OrderedInvocationMessageDispatcherFactory", invocationFactoryMessage);
}

[Fact]
public async Task DispatcherFactory_CanBeOverridden_WithAppSetting()
{
_testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsFeatureFlags, ScriptConstants.FeatureFlagDisableOrderedInvocationMessages);
await CreateDefaultWorkerChannel();
var invocationFactoryMessage = _logger.GetLogMessages().Select(m => m.FormattedMessage).Single(m => m.Contains("Factory"));
Assert.Contains("ThreadPoolInvocationProcessorFactory", invocationFactoryMessage);
}

[Fact]
public async Task DispatcherFactory_CanBeOverridden_WithHostingConfig()
{
// Without this feature flag, this test fails every time on multi-core machines as the logs will
// be processed out-of-order
_testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebJobsFeatureFlags, ScriptConstants.FeatureFlagEnableOrderedInvocationmessages);
_hostingConfigOptions.Value.EnableOrderedInvocationMessages = false;
await CreateDefaultWorkerChannel();
var invocationFactoryMessage = _logger.GetLogMessages().Select(m => m.FormattedMessage).Single(m => m.Contains("Factory"));
Assert.Contains("ThreadPoolInvocationProcessorFactory", invocationFactoryMessage);
}

[Fact]
public async Task Log_And_InvocationResult_OrderedCorrectly()
{
await CreateDefaultWorkerChannel();
_metricsLogger.ClearCollections();

Expand Down

0 comments on commit 4685e06

Please sign in to comment.