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: More robust shutdown/cleanup/reset #188

Conversation

austindrenski
Copy link
Member

Previously, we shutdown the consumer thread causing any reuse of the Api to block on the second event emitted to the event executor.

Fixes: #186


Stumbled into this one while working on #181 in which I've added unit tests that each setup their own independent IHost and then dispose of it at the conclusion of each test case.

But since the Api.Instance is inherently static/shared, subsequent test cases were observed blocking until CI timeout occurred.

This PR could reasonably be criticized for going a step too far by introducing a new dependency on Microsoft.Bcl.AsyncInterfaces, but I decided to propose it anyways on the basis that Microsoft.Bcl.AsyncInterfaces is a transitive dependency of Microsoft.Extensions.DependencyInjection.Abstractions which itself is a transitive dependency of Microsoft.Extensions.Logging.Abstractions >= 8.0.0, and only applies to TFMs that do not ship IAsyncDisposable and friends in-the-box, i.e., net462 and netstandard2.0.

An even cleaner solution would be to just bump our minimum required version of Microsoft.Extensions.Logging.Abstractions to 8.0.0 at which point Microsoft.Bcl.AsyncInterfaces comes transitively for free. I would prefer to do this, but figured that might be too controversial right before a release. (That said, if you like this idea too, please chime in because I have a strong belief that exceedingly few consumers in the wild actually need us to keep our MELA dependency pinned back in 2017. The newer versions of MELA are available for all of the relevant TFMs, which ought to mean there's no dependency hell argument at play on this one.)

@austindrenski austindrenski requested a review from a team as a code owner January 17, 2024 14:59
@austindrenski austindrenski force-pushed the more-robust-shutdown-cleanup-and-reset branch from 4c5d79f to 2f17a64 Compare January 17, 2024 15:05
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (1a14f6c) 0.00% compared to head (f8ada7d) 93.86%.

Files Patch % Lines
src/OpenFeature/EventExecutor.cs 90.90% 2 Missing ⚠️
src/OpenFeature/Api.cs 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main     #188       +/-   ##
=========================================
+ Coverage      0   93.86%   +93.86%     
=========================================
  Files         0       23       +23     
  Lines         0      946      +946     
  Branches      0      105      +105     
=========================================
+ Hits          0      888      +888     
- Misses        0       34       +34     
- Partials      0       24       +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

austindrenski added a commit to austindrenski/open-feature-dotnet-sdk that referenced this pull request Jan 17, 2024
austindrenski added a commit to austindrenski/open-feature-dotnet-sdk that referenced this pull request Jan 17, 2024
austindrenski added a commit to austindrenski/open-feature-dotnet-sdk that referenced this pull request Jan 17, 2024
@austindrenski austindrenski force-pushed the more-robust-shutdown-cleanup-and-reset branch from 2f17a64 to 66bf351 Compare January 17, 2024 18:50
Copy link
Member

@askpt askpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a small suggestion concerning the package installation.

src/OpenFeature/OpenFeature.csproj Outdated Show resolved Hide resolved
@austindrenski austindrenski force-pushed the more-robust-shutdown-cleanup-and-reset branch from 66bf351 to 2c197d8 Compare January 18, 2024 12:29
@austindrenski austindrenski requested a review from askpt January 18, 2024 12:31
Copy link
Member

@askpt askpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Coverage is lower so it is failing at the moment.

Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find something to nitpick, but I couldn't! 😅

@toddbaert
Copy link
Member

An even cleaner solution would be to just bump our minimum required version of Microsoft.Extensions.Logging.Abstractions to 8.0.0 at which point Microsoft.Bcl.AsyncInterfaces comes transitively for free. I would prefer to do this, but figured that might be too controversial right before a release.

Let's do this after this upcoming release, maybe?

@austindrenski
Copy link
Member Author

An even cleaner solution would be to just bump our minimum required version of Microsoft.Extensions.Logging.Abstractions to 8.0.0 at which point Microsoft.Bcl.AsyncInterfaces comes transitively for free. I would prefer to do this, but figured that might be too controversial right before a release.

Let's do this after this upcoming release, maybe?

Yeah, that's sounds fair. Plus, it'll dovetail nicely with #189 which also shouldn't land until after the upcoming release is finalized.

Previously, we shutdown the consumer thread causing any reuse of the
Api to block on the second event emitted to the event executor.

Fixes: open-feature#186

Signed-off-by: Austin Drenski <austin@austindrenski.io>
@austindrenski austindrenski force-pushed the more-robust-shutdown-cleanup-and-reset branch from 14aacac to f8ada7d Compare January 19, 2024 18:35
austindrenski added a commit to austindrenski/open-feature-dotnet-sdk that referenced this pull request Jan 19, 2024
@toddbaert toddbaert merged commit a790f78 into open-feature:main Jan 19, 2024
11 checks passed
@austindrenski austindrenski deleted the more-robust-shutdown-cleanup-and-reset branch January 19, 2024 22:46
beeme1mr pushed a commit that referenced this pull request Apr 9, 2024
This PR updates `OpenFeature` to use the latest MELA source generators
to produce compile-time logging delegates.

The most obvious critique of this PR is likely to be that, much like
#188, this PR changes the dependency graph by bumping our MELA
dependency from `[2.0.0,) => [8.0.0,)`.

To that^ critique, I continue to contend that depending on an ancient
version of MELA is unlikely to aid many real-world consumers of this
SDK, since new versions of MELA provide robust TFM coverage, as well as
my personal disbelief that anyone looking to consume this library in
2024 is deploying an app that won't already have transitively referenced
MELA `8.0.0` somewhere in its package graph.

_(If you are a user or potential user of this SDK and have a real-world
use case of a legacy app that __does not and cannot__ reference MELA `>=
8.0.0`, please ping back here! Would love to hear from you and adjust my
disbelief accordingly!)_

_(Note: if this PR lands before #188, then I'll update #188 to remove
its added dependency on `Microsoft.Bcl.AsyncInterfaces`, since it flows
transitively from MELA `8.0.0`.)_

Upon request, I am happy to provide a soapbox diatribe on why I think we
should care about source generators, hook perf, and incidental logging
allocations, especially as an SDK that wants to be trusted and baked
into all kinds of consumer apps, but eliding that for now in favor of
some docs refs:
-
https://learn.microsoft.com/dotnet/core/extensions/high-performance-logging
-
https://learn.microsoft.com/dotnet/core/extensions/logger-message-generator

Signed-off-by: Austin Drenski <austin@austindrenski.io>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
askpt added a commit that referenced this pull request Apr 11, 2024
This PR updates `OpenFeature` to use the latest MELA source generators
to produce compile-time logging delegates.

The most obvious critique of this PR is likely to be that, much like
#188, this PR changes the dependency graph by bumping our MELA
dependency from `[2.0.0,) => [8.0.0,)`.

To that^ critique, I continue to contend that depending on an ancient
version of MELA is unlikely to aid many real-world consumers of this
SDK, since new versions of MELA provide robust TFM coverage, as well as
my personal disbelief that anyone looking to consume this library in
2024 is deploying an app that won't already have transitively referenced
MELA `8.0.0` somewhere in its package graph.

_(If you are a user or potential user of this SDK and have a real-world
use case of a legacy app that __does not and cannot__ reference MELA `>=
8.0.0`, please ping back here! Would love to hear from you and adjust my
disbelief accordingly!)_

_(Note: if this PR lands before #188, then I'll update #188 to remove
its added dependency on `Microsoft.Bcl.AsyncInterfaces`, since it flows
transitively from MELA `8.0.0`.)_

Upon request, I am happy to provide a soapbox diatribe on why I think we
should care about source generators, hook perf, and incidental logging
allocations, especially as an SDK that wants to be trusted and baked
into all kinds of consumer apps, but eliding that for now in favor of
some docs refs:
-
https://learn.microsoft.com/dotnet/core/extensions/high-performance-logging
-
https://learn.microsoft.com/dotnet/core/extensions/logger-message-generator

Signed-off-by: Austin Drenski <austin@austindrenski.io>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
arttonoyan pushed a commit to arttonoyan/dotnet-sdk that referenced this pull request Nov 17, 2024
Signed-off-by: Austin Drenski <austin@austindrenski.io>
Signed-off-by: Artyom Tonoyan <artonoyan@servicetitan.com>
arttonoyan pushed a commit to arttonoyan/dotnet-sdk that referenced this pull request Nov 17, 2024
This PR updates `OpenFeature` to use the latest MELA source generators
to produce compile-time logging delegates.

The most obvious critique of this PR is likely to be that, much like
open-feature#188, this PR changes the dependency graph by bumping our MELA
dependency from `[2.0.0,) => [8.0.0,)`.

To that^ critique, I continue to contend that depending on an ancient
version of MELA is unlikely to aid many real-world consumers of this
SDK, since new versions of MELA provide robust TFM coverage, as well as
my personal disbelief that anyone looking to consume this library in
2024 is deploying an app that won't already have transitively referenced
MELA `8.0.0` somewhere in its package graph.

_(If you are a user or potential user of this SDK and have a real-world
use case of a legacy app that __does not and cannot__ reference MELA `>=
8.0.0`, please ping back here! Would love to hear from you and adjust my
disbelief accordingly!)_

_(Note: if this PR lands before open-feature#188, then I'll update open-feature#188 to remove
its added dependency on `Microsoft.Bcl.AsyncInterfaces`, since it flows
transitively from MELA `8.0.0`.)_

Upon request, I am happy to provide a soapbox diatribe on why I think we
should care about source generators, hook perf, and incidental logging
allocations, especially as an SDK that wants to be trusted and baked
into all kinds of consumer apps, but eliding that for now in favor of
some docs refs:
-
https://learn.microsoft.com/dotnet/core/extensions/high-performance-logging
-
https://learn.microsoft.com/dotnet/core/extensions/logger-message-generator

Signed-off-by: Austin Drenski <austin@austindrenski.io>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Co-authored-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: Artyom Tonoyan <artonoyan@servicetitan.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Api.Shutdown() hangs on reuse
3 participants