Try our conversational search powered by Generative AI!

Smooth Deploy Internal Exception

Vote:
 

Hello,

We are trying to implement Smooth Deploy and we believe we have made the necessary updates to our codebase. However, there is an exception thrown by EPiServer Initialization that we cannot seem to get around. The stack trace is as follows:

EPiServer.Framework.Initialization.InitializationException
  HResult=0x80131500
  Message=Initialize action failed for Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=12.12.1.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7
  Source=EPiServer.Framework
  StackTrace:
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()
   at EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(Boolean continueTransitions)
   at EPiServer.Framework.Initialization.InitializationEngine.Initialize()
   at EPiServer.Hosting.Internal.EPiServerFrameworkHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at ProductPlatform.Program.Main(String[] args) in C:\<localpath>\Program.cs:line 15

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
NotSupportedException: Automatic database schema update is prevented since the application is set to ReadOnly mode. The mode can be changed by setting DataAccesssOptions.DatabaseMode.

After decompiling EPiServer.Data.dll and following the initialization calls I arrived at the following line from EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation:

List<DatabaseSchemaManagerImplementation.DatabaseUpdater> list2 = list1.Where<DatabaseSchemaManagerImplementation.DatabaseUpdater>((Func<DatabaseSchemaManagerImplementation.DatabaseUpdater, bool>) (s => s.Status.ApplicationRequiredVersion > s.Status.DatabaseVersion)).ToList<DatabaseSchemaManagerImplementation.DatabaseUpdater>();


To me, this sounds like its trying to update the DB schema because it sees that the DB version is out of date. Thats not too surprising because we have our own code-first migrations. However, is there a way to get around this when the database is in read only mode?

#299218
Edited, Mar 29, 2023 20:58
Vote:
 

Hi,

I'd say that does sound surprising as there shouldn't be any changes in the schema to update. The way smooth deploy should work is that a copy of the existing web app and database (in read-only mode) is made. Live web traffic is then pointed at the read-only copy of the site while the new codebase is deployed to the original web app, pointed at the original read/write instance of the database. The read-only version of the site is a copy of what was already there so no schema update should be required. Any changes which have been made in the codebase as part of the new release which require a schema update would be deployed to the read/write version of the site so shouldn't have any issues updating the schema.

You could potentially switch off schema updates when the DB is in read-only mode by doing something like this in your startup.cs:

services.Configure<DataAccessOptions>(o => o.UpdateDatabaseSchema = ServiceLocator.Current.GetInstance<IDatabaseMode>().DatabaseMode.Equals(DatabaseMode.ReadWrite));

I've not checked whether that would work but I suspect, even if it did, you'd just end up with an error telling you that the schema needs updating.

If it's practical to do so, you could deploy using smooth deploy in read/write mode though you'd need to ensure you're happy to lose any changes which are made to the database during the deploy (e.g. content changes, form submissions, etc.).

#299299
Mar 31, 2023 8:42
Vote:
 

Great suggestion, Paul. You were also correct that it lead to another error down the line. In addition, changing the database mode to "ReadWrite" gave us a more specific error: 

warn: EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister[0]
     Changes in the model were ignored because its version(0.0.0.0) is lower than version in the database(0.5).
#299460
Apr 03, 2023 21:38
Vote:
 

One thing that caught our attention this morning is the following line from this (https://docs.developers.optimizely.com/digital-experience-platform/docs/smooth-deploy) page:

Smooth deployment is available for Optimizely Content Management System (CMS) only.

This raised our eyebrows because we are attempting to implement smooth deploy on a commerce site. In my last response, I only gave partial output. However, the full stack-trace shows that our error is thrown from a mediachase namespace:

EPiServer.Framework.Initialization.InitializationException: 'Initialize action failed for Initialize on class EPiServer.Initialization.Internal.ModelSyncInitialization, EPiServer, Version=12.12.1.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()
   at EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(Boolean continueTransitions)
   at EPiServer.Framework.Initialization.InitializationEngine.Initialize()
   at EPiServer.Hosting.Internal.EPiServerFrameworkHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at ProductPlatform.Program.Main(String[] args) in C:\<localpath>\Program.cs:line 15
Inner exception: NotSupportedException: Database writes are blocked since the application is set to ReadOnly mode. ReadOnly mode is set either by the 'databaseMode' attribute on the 'episerver.dataStore' section or by the 'episerver:DatabaseMode' setting under the 'appSettings' section.
   at Mediachase.Data.Provider.DataService.ThrowIfReadonlyMode()
   at Mediachase.MetaDataPlus.Configurator.MetaDataPlusDatabase.UpdateMetaField(MetaDataContext context, Int32 metaFieldId, String fieldNamespace, String friendlyName, String description, Object tag)
   at Mediachase.MetaDataPlus.Configurator.MetaField.set_Description(String value)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.UpdateMetaField(PropertyDefinitionModel propertyDefinitionModel, MetaField metaField)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.CreateOrUpdateMetaField(MetaClass metaClass, PropertyDefinitionModel propertyDefinitionModel)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.AssignModelPropertiesToMetaClass(MetaClass metaClass, IEnumerable`1 propertyDefinitionModels)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.AssignValuesToProperties(ContentTypeModel contentTypeModel)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.AssignValuesToProperties(ContentTypeModel modelType)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.AddModel(Type type)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.RegisterModels()
   at EPiServer.Initialization.Internal.ModelSyncInitialization.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

Are we restricted from implementing smooth deploy because its a commerce site?

#299841
Edited, Apr 10, 2023 16:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.