Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus] Handle cases where desired worker count exceeds int.MaxInt #39474

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,17 @@ internal TargetScalerResult GetScaleResultInternal(TargetScalerContext context,
throw new ArgumentOutOfRangeException($"Unexpected concurrency='{concurrency}' - the value must be > 0.");
}

int targetWorkerCount = (int)Math.Ceiling(messageCount / (decimal)concurrency);
int targetWorkerCount;

try
jsquire marked this conversation as resolved.
Show resolved Hide resolved
{
targetWorkerCount = (int)Math.Ceiling(messageCount / (decimal)concurrency);
}
catch (OverflowException)
{
targetWorkerCount = int.MaxValue;
}

_logger.LogInformation($"Target worker count for function '{_functionId}' is '{targetWorkerCount}' (EntityPath='{_entityPath}', MessageCount ='{messageCount}', Concurrency='{concurrency}').");

return new TargetScalerResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public void Setup()
[TestCase(100, true, true, null, 4)]
[TestCase(100, false, true, 19, 6)]
[TestCase(100, false, false, null, 3)]
public void ServiceBusTargetScaler_Returns_Expected(int messageCount, bool isSessionEnabled, bool singleDispatch, int? concurrency,int expected)
[TestCase(100, false, false, null, 3)]
[TestCase(2147483650, false, false, 1, 2147483647)] // cap targetWorkerCount at int.MaxValue
[TestCase(2147483650, false, false, 2, 1073741825)]
public void ServiceBusTargetScaler_Returns_Expected(long messageCount, bool isSessionEnabled, bool singleDispatch, int? concurrency, int expected)
{
ServiceBusOptions options = new ServiceBusOptions
{
Expand Down