-
Notifications
You must be signed in to change notification settings - Fork 874
fix http concurrency #4218
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
fix http concurrency #4218
Conversation
Add tests handle edge cases and add unit tets update tests info add integ tests stack-info: PR: #4218, branch: GarrettBeatty/gcbeatty/taskoptimization/1
610a889 to
91abd13
Compare
| } | ||
| } | ||
|
|
||
| /// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should eventually refactor this to get rid of the extra discoverdownloadstrategy function. since its a little confusing that the semaphore releases go across functions (between discoverdownloadstrategy and startdownload). i plan on doing that after we fix all of the bugs
| } | ||
|
|
||
| [TestMethod] | ||
| public async Task DiscoverUsingPartStrategy_AcquiresAndReleasesHttpSlot() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are no longer applicable since they asserted old (and incorrect behavior)
| // Act - Start both discoveries concurrently | ||
| var task1 = coordinator1.DiscoverDownloadStrategyAsync(CancellationToken.None); | ||
| var task2 = coordinator2.DiscoverDownloadStrategyAsync(CancellationToken.None); | ||
| var discovery1 = await coordinator1.DiscoverDownloadStrategyAsync(CancellationToken.None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to update these because now with new change the semaphore is held through start download, so callers need to do discover + start download in order to get through the whole http cycle
Stacked PRs:
Description
Fix HTTP concurrency for multi part download. Previously we were releasing the http semaphore slot after we got the http response but before we read the response body (wrote it to a file/stream). This meant that it was possible for there to be more active
ConcurrentServiceRequeststhan the user actually wanted.The fix was to move the releasing of the http semaphore slot after processing the part. This ensured that its only released once its written to the file/stream and ensures only
ConcurrentServiceRequestsare active at a time.Motivation and Context
#3806
Testing
HttpSemaphore_HeldThroughProcessPartAsyncwhich verify that the http semaphore is only released after process part is executed. In order to ensure this test actually checks the issue, i ran it before my fix and the test failed (as expected). After my fix, the test passes.Screenshots (if appropriate)
Before (we can see concurrency is over the set 10)

After, we can see concurrency stays at or below 10

Types of changes
Checklist
License