Closed bkclerke closed 5 years ago
Thanks @bkclerke ! We have done work in the past to make this error at least detailed and a bit more friendly and we thought it should not happen any more but apparently there's still a race condition where this gets triggered. Is there a way you can easily reproduce this error?
Yes! I just setup a local instance of v8.0.2. It has no starterkit and using SQL CE to just get it up quickly. I created a homepage doctype with a template. Put 2 test properties on it. No problems with the front end of the site loading when I make changes with only 1 doctype in there. When I created a second doctype and saved it (1 test property), i refreshed the front end of the site and I see the error:
Cannot bind source content type Umbraco.Web.PublishedModels.Home to model type Umbraco.Web.PublishedModels.Home. Both view and content models are PureLive, with different versions. The application is in an unstable state and is going to be restarted. The application is restarting now.
My Home template is using the default inherit and using content models that are created with a template and I simply added Model.Title and Model.BodyText to them to render the two properties I made on my homepage. The second doctype I only added 1 property on, title / textstring, with no template and after saving and publishing I was able to hit the error.
Edit: My content area has the Home doctype published with the title and body text on it for testing. Those were the only things I did to replicate the error.
Hopefully that helps.
I've had similar issues in Umbraco 7 for quite some time. They're not easily reproducible, I haven't been able to create a sequence of steps. I'm using VS 2017, and ModelsBuilder in AppData mode. Sebastiaan, you're mentioning a race condition, do you have more details?
I have added some code to detect the error when it happens (no work around), and here is a screenshot:
This item has been added to our backlog AB#1495
The reason for this happening is the use of the models generated by modelsbuilder, to populate the object-based cache in V8. Whenever a document type is saved - all models are regenerated (recompiles everything - also classes that haven't actually changed).
What we do is to then tell the cache that it should regenerate the cached data for the document type being saved - which causes the data in the cache to be repopulated, which is also why you should see that it sometimes seems like it actually just works.
The problem is however that since all model classes have been regenerated - the objects in the cache (not of the exact type that we have been clearing cache for) are no longer .NET-class-wise made using the same types as the types we now have and therefore we see the issue of not being able to bind the data between these two types. Although the types may look and seem very much like the same type - they are considered different types due to being recompiled.
What you would see as a result of this is that when resaving a document type - the data cached for that document type should actually work. However, cached data for all other document types should now be invalid in regards to being used for binding.
What we need to do is to ensure that whenever we have to regenerate all models - everything that was using the old models (in the cache) needs to be cleared so it can be repopulated with the correct types.
Thank you so much for being awesome and fixing this issue. You guys are amazing! :)
Forum thread for reference.
I've tried this on v8.0.1 and v8.0.2 and am able to replicate the issue. When making changes to a doctype and refreshing the front end of the website I am receiving the following error:
Cannot bind source content type Umbraco.Web.PublishedModels.PcGridLayout to model type Umbraco.Web.PublishedModels.PcGridLayout. Both view and content models are PureLive, with different versions. The application is in an unstable state and is going to be restarted. The application is restarting now.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedModels.PcGridLayout to model type Umbraco.Web.PublishedModels.PcGridLayout. Both view and content models are PureLive, with different versions. The application is in an unstable state and is going to be restarted. The application is restarting now.
I've been able to fix the error by waiting for the application to restart or touching the web.config before I load the front end of the site.
Also, I'm curious if this might be related to fix this issue too?