umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.36k stars 2.64k forks source link

Getting error "Connection string changed, disposing context" when enabling Content Delivery API #16624

Open fbpenalosa opened 1 week ago

fbpenalosa commented 1 week ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.3.6

Bug summary

We are getting getting error "Connection string changed, disposing context" after we save and publish content nodes when Content Delivery API is enabled

Specifics

Additional Specs: Umbraco 12.3.6 USkinned 5.2.0 USyn 12.2.3

Issue Details We've recently enabled Content Delivery API. After doing that we noticed that we are getting this warning error after we save and publish any content nodes:

“Connection string changed, disposing context“

Here's an example screenshot of the event:

image

In this example, two of those errors got logged after we published a content node.

Here's some details for that log: image

We got rid of these errors for now by completely disabling the Content Delivery API, meaning:

I'm not sure what's going or if we need to adjust something

Steps to reproduce

Enable Content Delivery API by following the manual: https://docs.umbraco.com/umbraco-cms/v/12.latest/reference/content-delivery-api#enable-the-content-delivery-api

  1. Enable in AppSettings.config

image

  1. Add Delivery API in Startup.cs service builder image

  2. Save and publish any content page

Please note that we're unable to replicate this locally. These were observed and replicated in deployed instances.

Expected result / actual result

No errors on logs when saving and publishing content pages while Content Delivery API is enabled

github-actions[bot] commented 1 week ago

Hi there @fbpenalosa!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

Migaroez commented 2 days ago

Hey @fbpenalosa, thank you for reaching out and taking the time to flesh out this report.

Have you been able to reproduce this on a deployed instance with just umbraco running? So removing all packages including usync/uskinned?

fbpenalosa commented 2 days ago

@Migaroez Thank you for the response.

Unfortunately, it's not possible to remove USync and USkinned as both of them are baked in our products and thus all of our deployed instances have them.

It's very interesting though that I cannot replicate this on my local instance which makes this hard to trace. Would there be any difference on how CDA gets implemented locally vs on a deployed instance? As soon as I turn-off CDA by setting Enabled = False and removing AddDeliveryAPI() from Startup.cs, these warnings go away.

Migaroez commented 2 days ago

There are no differences between local and deployed except for configuration and environment. If there is an increased access delay towards the persistence layer (sql database) then a race condition/timeout/... can explain a difference in behavior.

It seems very similar to this https://github.com/umbraco/Umbraco-CMS/issues/15090 And we partly fixed it in https://github.com/umbraco/Umbraco-CMS/pull/15410 which you already have active on your installation.

A follow up mitigation of the race condition was fixed in https://github.com/umbraco/Umbraco-CMS/pull/15649

Could you try and update one of your solutions to v13.1.1+ to see if this resolves the problem?

shallett-ghd commented 1 day ago

There are no differences between local and deployed except for configuration and environment. If there is an increased access delay towards the persistence layer (sql database) then a race condition/timeout/... can explain a difference in behavior.

It seems very similar to this #15090 And we partly fixed it in #15410 which you already have active on your installation.

A follow up mitigation of the race condition was fixed in #15649

Could you try and update one of your solutions to v13.1.1+ to see if this resolves the problem?

There would be no appetite to merge this fix into version 12 I'm assuming?

Migaroez commented 1 day ago

I am afraid not as v12 entered the security phase at the end of march.

Any reason why upgrading to v13 is not feasable? It should be a fairly easy upgrade and most mainstream packages have been available for v13 for a while and its an LTS afterall

shallett-ghd commented 1 day ago

Not that it's not feasible, it's just a longer development cycle than the need to enable this API allows.

As this is just a warning, what are the side effects of enabling this API with this occurring?