Try our conversational search powered by Generative AI!

Using smooth deploy with ContentProvider

Vote:
 

Hi, we have a CMS11 solution that uses an external contentprovider trying to show images on certain pages.
We are also trying to get the site to deploy smoothly to DXP but are facing errors on pages with the above mentioned images from content-provider when doing LoadContent and calling IdentityMappingService.Get method when figuring out contentitems parent. 

According to my understanding it should be possible to get mappedIdentity without creating missing mapping by simply setting the createMissingMappings to false, however the code ends up in IdentityMappingDB class to this particular method:


      using (SqlCommand command = (SqlCommand) this.CreateCommand("netMappedIdentityGetOrCreate"))
        {
          command.Parameters.Add((object) this.CreateParameter("CreateIfMissing", (object) createMissingMappings));
          System.Collections.Generic.List<SqlDataRecord> uriPartsTable = this.CreateUriPartsTable(externalIdentitifiers);
          SqlParameter sqlParameter = command.Parameters.AddWithValue("@ExternalIds", (object) uriPartsTable);
          sqlParameter.SqlDbType = SqlDbType.Structured;
          sqlParameter.TypeName = "UriPartsTable";
          return this.ExecuteListUriCommand(command);
        }

And this is where it fails, because our content db is on ReadOnly state when doing a smooth deploy. Are there any known workarounds or best practises for ContentProviders for such scenarios? 
 

#292850
Edited, Dec 08, 2022 10:12
Vote:
 

I do think we have the images, the page's start showing YSOD only after we set the database to readonly. 
However, we do a lookup of mapped content and it's contentfolder structure when Loading content. Could that be the reason why all hell breaks loose? 

#292858
Dec 08, 2022 14:07
Quan Mai - Dec 08, 2022 14:17
I thought you meant you posted images for the error. My bad. Can you post the full stacktrace ?
Vote:
 

Here's the stacktrace:



[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.]
   EPiServer.Data.Providers.Internal.ReadOnlySqlDatabaseExecutor.ExecuteTransaction(Func`1 action) +62
   EPiServer.DataAbstraction.IdentityMappingService.Get(Uri externalIdentifier, Boolean createMissingMapping) +73
   XXXX.Web.Business.ZZZZ.ZZZZContentProvider.Convert(ZZZZFolder folder) in C:\projects\XXXX\Web\Business\ZZZZ\ZZZZContentProvider.cs:190
   XXXX.Web.Business.ZZZZ.ZZZZContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) in C:\projects\XXXX\Web\Business\ZZZZ\ZZZZContentProvider.cs:55
   EPiServer.Core.<>c__DisplayClass127_0.<LoadContentFromCacheOrRepository>b__0() +35
   EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait(IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy) +1035
   EPiServer.Core.Internal.ContentInstanceCache.ReadThrough(ContentReference contentLink, String selectedLanguage, Func`1 readValue) +107
   EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +618
   EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions) +327
   EPiServer.Core.Internal.DefaultContentLoader.TryGet(ContentReference contentLink, LoaderOptions loaderOptions, T& content) +577
   EPiServer.Core.Internal.DefaultContentLoader.Get(ContentReference contentLink, LoaderOptions loaderOptions) +99
   XXXX.Web.Business.ZZZZ.ZZZZContentProvider.Convert(ZZZZAsset file, String id, String parent) in C:\projects\XXXX\Web\Business\ZZZZ\ZZZZContentProvider.cs:118
   XXXX.Web.Business.ZZZZ.ZZZZContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) in C:\projects\XXXX\Web\Business\ZZZZ\ZZZZContentProvider.cs:63
   EPiServer.Core.<>c__DisplayClass127_0.<LoadContentFromCacheOrRepository>b__0() +35
   EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait(IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy) +1035
   EPiServer.Core.Internal.ContentInstanceCache.ReadThrough(ContentReference contentLink, String selectedLanguage, Func`1 readValue) +107
   EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +618
   EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions) +327
   EPiServer.Core.Internal.DefaultContentLoader.TryGet(ContentReference contentLink, LoaderOptions loaderOptions, T& content) +577
   EPiServer.Web.Routing.Internal.DefaultUrlResolver.SelectValidUrlLanguage(ContentReference contentLink, ContextMode contextMode, IContent& content) +189
   EPiServer.Web.Routing.Internal.DefaultUrlResolver.GetUrl(ContentReference contentLink, String language, VirtualPathArguments virtualPathArguments) +119
   EPiServer.Web.Mvc.Html.UrlExtensions.ContentUrl(UrlHelper urlHelper, ContentReference contentLink) +81
   XXXX.Web.Models.Pages.SitePage.CreateContentHighlightItem() in C:\projects\XXXX\Web\Models\Pages\Site\SitePage.cs:145
   XXXX.Web.Mvc.PageViewContextFactory.GetSharingImageUrl(SiteStartPage startPage, PageData currentPage) in C:\projects\XXXX\Web\Mvc\PageViewContextFactory.cs:170
   XXXX.Web.Mvc.PageViewContextFactory.CreateHKLayoutModel(SiteStartPage siteStartPage, PageData currentContent, IContentLoader contentLoader) in C:\projects\XXXX\Web\Mvc\PageViewContextFactory.cs:224
   XXXX.Web.Mvc.PageViewContextFactory.CreateLayoutModel(ContentReference currentPageLink, RequestContext requestContext) in C:\projects\XXXX\Web\Mvc\PageViewContextFactory.cs:110
   XXXX.Web.Controllers.SitePageController`1.OnActionExecuted(ActionExecutedContext filterContext) in C:\projects\XXXX\Web\Controllers\Site\SitePageController.cs:49
   System.Web.Mvc.Async.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +95
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +50
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +43
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +651
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134


I possibly found a way to circumvent it with getting the full list of available MappedIdentities out with IdentityMappingService's public List property and filtering the correct MappedIdentity from there without doing a lookup in DB. But not sure yet of the impact, need to test :)

#292860
Edited, Dec 08, 2022 14:46
* 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.