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

Fix race condition in the creation of scoped kernels #1076

Merged
merged 18 commits into from
Jul 24, 2024
Merged

Fix race condition in the creation of scoped kernels #1076

merged 18 commits into from
Jul 24, 2024

Conversation

glahaye
Copy link
Contributor

@glahaye glahaye commented Jul 24, 2024

Motivation and Context

Calling Build() on a Kernel builder causes an update to the list of DI services. Those services are also iterated over in Build(). Since the code only had one copy of the list of services, multiple simultaneous calls to Build() could modify the list while it was being iterated over, causing the bug described at #916

Description

Instead of calling Build for each instance of a kernel desired, we now create a single kernel and clone it when a new instance is desired.

Contribution Checklist

@glahaye glahaye self-assigned this Jul 24, 2024
@github-actions github-actions bot added the webapi Pull requests that update .net code label Jul 24, 2024
@glahaye glahaye added bug Something isn't working and removed webapi Pull requests that update .net code labels Jul 24, 2024
@glahaye glahaye linked an issue Jul 24, 2024 that may be closed by this pull request
@glahaye glahaye merged commit 7f34901 into microsoft:main Jul 24, 2024
7 checks passed
@glahaye glahaye deleted the race_condition branch July 25, 2024 00:54
teamleader-dev pushed a commit to vlink-group/chat-copilot that referenced this pull request Oct 7, 2024
### Motivation and Context
Calling Build() on a Kernel builder causes an update to the list of DI
services. Those services are also iterated over in Build(). Since the
code only had one copy of the list of services, multiple simultaneous
calls to Build() could modify the list while it was being iterated over,
causing the bug described at microsoft#916

### Description
Instead of calling Build for each instance of a kernel desired, we now
create a single kernel and clone it when a new instance is desired.

### Contribution Checklist
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
kb0039 pushed a commit to aaronba/chat-copilot that referenced this pull request Jan 8, 2025
### Motivation and Context
Calling Build() on a Kernel builder causes an update to the list of DI
services. Those services are also iterated over in Build(). Since the
code only had one copy of the list of services, multiple simultaneous
calls to Build() could modify the list while it was being iterated over,
causing the bug described at microsoft#916

### Description
Instead of calling Build for each instance of a kernel desired, we now
create a single kernel and clone it when a new instance is desired.

### Contribution Checklist
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webapi exception
1 participant