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 disposed DbContext issue (#15090) #15410

Merged
merged 1 commit into from
Dec 10, 2023

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Dec 8, 2023

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #15090

Description

The InitializeMemberApplicationNotificationHandler is invoked at start-up - also during install. Problem is... it has an indirect dependency on UmbracoDbContext, which ultimately causes the linked issue in rare cases (it's a timing thing).

This PR ensures that InitializeMemberApplicationNotificationHandler resolves the IMemberApplicationManager at runtime instead of through the DI, which in turn ensures that the handler does not have a DI bound dependency on UmbracoDbContext.

Furthermore we're now throwing an exception in UmbracoDbContext if the connection string has not yet been set. This should prevent these kinds of issues from escalating in the future.

The exception throwing in UmbracoDbContext also means that UmbracoPooledDbContextFactory is no longer necessary. This was initially introduced as an attempted workaround to the same root cause.

Testing this PR

It should be possible to install V12.3.4 😄

Install should be performed with and without MemberAuthorization configured for the Delivery API (see docs):

  • When configured, the umbracoOpenIddictApplications table should reflect the configuration after install.
  • When not configured (or not enabled), the table should be empty.

@bergmania bergmania merged commit d752853 into release/12.3.4 Dec 10, 2023
14 checks passed
@bergmania bergmania deleted the v12/fix/dbcontext-disposed-issue branch December 10, 2023 18:18
@niekvanderreest
Copy link
Contributor

Hi,

I'm running into "Connection string changed, disposing context" warnings after upgrading a project from umbraco 11.5 to 12.3.6, i don't see any errors and functionality seems to be what is was, but the warnings occur running an async task on and efCoreScopeProvider scope.

The project has Hangfire running on the umbraco database, the warnings occur while running a Hangfire job

image

Any idea if this is related, i would like to know the impact before pushing my upgrade to live (project is hosted on Umbraco Cloud)

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.

3 participants