From 0984ae3e01b8194a31c35844561987030777d735 Mon Sep 17 00:00:00 2001 From: Alexey Rodionov Date: Tue, 16 Jul 2024 11:11:12 -0700 Subject: [PATCH] Fixing target base scale instance concurrency for queues (#44661) * Fixing target base scale instance concurrency for queues * New commit * Adding changelog notes * Fix --------- Co-authored-by: Amanda Nguyen --- .../CHANGELOG.md | 8 ++------ .../src/Shared/Queues/QueueTargetScaler.cs | 4 ++-- .../CHANGELOG.md | 7 ++----- .../tests/QueueTargetScalerTests.cs | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/CHANGELOG.md b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/CHANGELOG.md index 5906f03422abc..cc4de68fcd802 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/CHANGELOG.md +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/CHANGELOG.md @@ -2,15 +2,11 @@ ## 5.4.0-beta.1 (Unreleased) -### Features Added - -### Breaking Changes - ### Bugs Fixed +- Rely on PeekMessagesAsync when calculating message queue length +- Fixing target base scale instance concurrency for queues - Bumped version of Azure.Storage.Blobs to resolve issue where Blob Path was being truncated at '#' character. -### Other Changes - ## 5.3.0 (2024-04-18) - Includes all features from 5.3.0-beta.1. - Bumped Azure.Identity dependency to 1.11.1 to resolve secruity vulnerability. diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/src/Shared/Queues/QueueTargetScaler.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/src/Shared/Queues/QueueTargetScaler.cs index 6da40f64a5b6b..d89c8fab535a4 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/src/Shared/Queues/QueueTargetScaler.cs +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/src/Shared/Queues/QueueTargetScaler.cs @@ -55,11 +55,11 @@ public async Task GetScaleResultAsync(TargetScalerContext co internal TargetScalerResult GetScaleResultInternal(TargetScalerContext context, int queueLength) { - int concurrency = !context.InstanceConcurrency.HasValue ? _options.BatchSize : context.InstanceConcurrency.Value; + int concurrency = !context.InstanceConcurrency.HasValue ? _options.BatchSize + _options.NewBatchThreshold : context.InstanceConcurrency.Value; if (concurrency < 0) { - throw new ArgumentOutOfRangeException($"Concurrency value='{concurrency}' used for target based scale must be > 0"); + throw new ArgumentOutOfRangeException($"Concurrency value='{concurrency}' used for target based scale must be > 0."); } int targetWorkerCount = (int)Math.Ceiling(queueLength / (decimal)concurrency); diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md index faebfb83f19f8..0dfcb541ea1ae 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/CHANGELOG.md @@ -2,13 +2,10 @@ ## 5.4.0-beta.1 (Unreleased) -### Features Added - -### Breaking Changes - ### Bugs Fixed +- Rely on PeekMessagesAsync when calculating message queue length +- Fixing target base scale instance concurrency for queues - When grabbing Queue Metrics for amount of messages, will now use the QueueTriggerMetrics.QueueLength instead of the ApproximateMessagesCount for less stale metrics. -### Other Changes ## 5.3.0 (2024-04-18) - Includes all features from 5.3.0-beta.1. diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/QueueTargetScalerTests.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/QueueTargetScalerTests.cs index 410be2e6e7494..cb69be0ca7774 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/QueueTargetScalerTests.cs +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/tests/QueueTargetScalerTests.cs @@ -32,7 +32,7 @@ public void Setup() [TestCase(160, 20, 8)] public void QueueTargetScaler_Returns_Expected(int queueLength, int? concurrency, int expectedTargetWorkerCount) { - QueuesOptions options = new QueuesOptions { BatchSize = 16 }; + QueuesOptions options = new QueuesOptions { BatchSize = 8, NewBatchThreshold = 8 }; TargetScalerContext context = new TargetScalerContext {