-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Issues with event counters #23630
Comments
@roji As I understand it, all we do in EF for event counters is to increment a value in Coming back to the static/global issue, it seems to me that some refactoring and changing of private code to pubternal could allow a test to be setup with an isolated EntityFrameworkEventSource that could be used in tests. This doesn't tell us that event counters are working end-to-end, but as you say others are not testing that either because of the issues you outline. However, it would give us a pattern for testing new event counters that verify at least that the "EF part" is working as expected. |
We could do this, but these counters aren't exposed publicly (at least not at the moment) - the only way to observe them right now is via the perf counters. If you think we should expose them, let me know and I'll do it (that would be introducing public surface in a patch).
I'm not sure the static/global issue is actually blocking testing - xunit does allow turning off parallelization for a specific test collection (with Basically I'm fine with anything here (especially after seeing the errors I missed) - let me know what you prefer me to do. Since the window for 5.0.2 is closing very soon, we may also want to merge this and add test coverage later in main. |
@roji And there is no way to inspect the perf counters programmatically? |
It's possible to connect and consume the counters just like the |
In case anyone's interested, here's the incomplete attempt at proper end-to-end coverage: |
Punting this out to 5.0.3; we don't need to rush this into 5.0.2. |
…ce testing Fixes #23630 **Description** Three event counters don't get updated when the async API is used (as opposed to the sync one). An additional event counter is incorrectly updated, and so show wrong results. **Customer Impact** Our newly-introduced event counters show incorrect data which does not take into account async calls. **How found** Customer reported an issue on 5.0.0 with one counter, the rest discovered via due diligence. **Test coverage** Test coverage added after investigation and discussion of the best way to do it. We settled on using reflection to access the counters and then configuring the tests to not run in parallel. These tests are both for detecting regressions, and so that going forward we can test new event counters to avoid mistakes like this in the future. **Regression?** No, event counters are new in 5.0.0. **Risk** Very low, add missing counter updates which are already in place and working for the sync versions, and move the location of another counter update. Only affects the new event counters feature.
The following counters don't get updated when the async API is used (as opposed to the sync one):
SaveChangesAsync
do not update theEntityFrameworkEventSource
values #23604)In addition, the "Active DbContexts" counter is incorrect, since it's incremented only when the context's InternalServiceProvider is accessed, but decremented when disposing (regardless of whether InternalServiceProvider was accessed). Am moving the increment to occur in the constructor, /cc @ajcvickers
Note: I've spent some considerable time preparing automated tests for event counters, however:
So am dropping this for now, but we can rediscuss if we feel we need to.
The text was updated successfully, but these errors were encountered: