2

I am using the Publishing Service in a Sitecore 10.2 Production environment. We use deployment slots in Azure App Services. Each deployment slot has a dedicated Web database, Slot 1 has Web and Slot 2 has Web2.

The publishing targets in the publishing service are setup and I am able to publish to both. However, only the Slot 1 CD updates it content. The Slot 2 CD tied to Web2 only updates if I restart the Slot Web App.

On the 2nd Slot, I have my connectionString named as "web" just like the first slot but it's database entry for the connectionString is to the web2 database.

I suspect that the events of publishing are getting discarded/not read by the Slot 2 CD Web App.

How should I configure my 2nd Slot Web App so that it updates on publish without restarting the whole app?

My Sitecore.Publishing.Service.Delivery.config is the default that comes with the Publishing Service Module:

<?xml version="1.0" encoding="utf-8"?>

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore role:require="Standalone or ContentDelivery or ContentManagement">
        <hooks>
            <hook type="Sitecore.Publishing.Service.Delivery.PublishTargetEventsHook, Sitecore.Publishing.Service.Delivery" resolve="true"/>
        </hooks>

        <!--
    SITECORE EVENTS
    -->
        <events>
            <event name="publishingservice:searchindex:rebuild">
                <handler type="Sitecore.Publishing.Service.Delivery.TargetSearchIndexRebuildHandler, Sitecore.Publishing.Service.Delivery" method="RebuildTargetSearchIndex">
                    <IndexNames hint="list:AddIndex">
                        <index>sitecore_web_index</index>
                    </IndexNames>
                </handler>
            </event>

            <event name="publishingservice:cache:clear">
                <handler type="Sitecore.Publishing.Service.Delivery.TargetDataCacheClearHandler, Sitecore.Publishing.Service.Delivery" method="ClearTargetDataCaches" />
            </event>
        </events>
    </sitecore>
</configuration>

Update: I have added a 2nd connectionString to my CD2 and the following configuration to use web2 (which properly applies website to be using web2), but the content is still not showing unless I restart the server (this could be either a CMS or the CD2 Web App restart).

Of note: In checking the Sitecore Desktop Content Editor, my publishing to Web shows all the content but but Web2 the Publishing Service says it has published, but items are not being updated/showing if you go into the Sitecore Desktop Content Editor for Web2 unless CMS/CD Web Apps are restarted to rebuild from the database.

    <?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">>
  <sitecore>
    <eventing defaultProvider="sitecore">
      <eventQueueProvider>
        <eventQueue name="web2" patch:after="eventQueue[@name='web']" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
          <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
          <param hint="" ref="PropertyStoreProvider/store[@name='$(name)']" />
        </eventQueue>
      </eventQueueProvider>
    </eventing>
    <PropertyStoreProvider>
      <store name="web2" patch:after="store[@name='web']" prefix="web2" getValueWithoutPrefix="true" singleInstance="true" type="Sitecore.Data.Properties.$(database)PropertyStore, Sitecore.Kernel">
        <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
        <param resolve="true" type="Sitecore.Abstractions.BaseEventManager, Sitecore.Kernel" />
        <param resolve="true" type="Sitecore.Abstractions.BaseCacheManager, Sitecore.Kernel" />
      </store>
    </PropertyStoreProvider>
    <databases>
      <!-- web_secondary -->
      <database id="web2" patch:after="database[@id='web']" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel">
        <param desc="name">$(id)</param>
        <icon>Images/database_web.png</icon>
        <securityEnabled>true</securityEnabled>
        <dataProviders hint="list:AddDataProvider">
          <dataProvider type="Sitecore.Data.DataProviders.CompositeDataProvider, Sitecore.Kernel">
          <param desc="readOnlyDataProviders" hint="list">
            <protobufItems type="Sitecore.Data.DataProviders.ReadOnly.Protobuf.ProtobufDataProvider, Sitecore.Kernel">
              <filePaths hint="list">
                <filePath>$(dataFolder)/items/$(id)</filePath>
                <modulesFilePath>/sitecore modules/items/$(id)</modulesFilePath>
              </filePaths>
            </protobufItems>
          </param>
      <param desc="headProvider">
              <dataProvider ref="dataProviders/main" param1="$(id)">
                <disableGroup>publishing</disableGroup>
                <prefetch hint="raw:AddPrefetch">
                  <sc.include file="/App_Config/Prefetch/Common.config" />
                  <sc.include file="/App_Config/Prefetch/Webdb.config" />
                </prefetch>
              </dataProvider>
            </param>
          </dataProvider>
        </dataProviders>
        <PropertyStore ref="PropertyStoreProvider/store[@name='$(id)']" />
        <remoteEvents.EventQueue>
          <obj ref="eventing/eventQueueProvider/eventQueue[@name='$(id)']" />
        </remoteEvents.EventQueue>
        <archives hint="raw:AddArchive">
          <archive name="archive" />
          <archive name="recyclebin" />
        </archives>
        <cacheSizes hint="setting">
          <data>100MB</data>
          <items>50MB</items>
          <paths>2500KB</paths>
          <itempaths>50MB</itempaths>
          <standardValues>2500KB</standardValues>
        </cacheSizes>
      </database>
    </databases>
        <sites>
    <site name="website" set:database="web2" />
    </sites>
  </sitecore>
</configuration>
2
  • 1
    Another thing to double check is that the instance names are correctly set on each of the CD instances. We had similar issue where caches were not clearing due to them not being set correctly. Commented Sep 2, 2023 at 8:39
  • Thank you. Will evaluate
    – Kode
    Commented Sep 2, 2023 at 13:56

2 Answers 2

3
+50

I think this is what's happening in your setup:

CM and Publishing Service know about two target databases: web and web2. Every time a publishing job is finished, CM sends a remote event called TargetDataCacheClearEvent and specifies the target database name in its parameters. For a publishing job to the first DB it is web, for the second DB it is web2:

Cache clear events

Then, each CD slot will listen to events from the connected web database and process them. This is how it works for Slot 2 CD in your configuration:

  • it receives a cache clear event for the database with name web2
  • it tries to get a database with this name and can't find it because the database is called web in the config
  • as there is no such database, the website can't clear caches for it:
Database database = this._factory.GetDatabase(parameter.EventData.DatabaseName);
if (database == null)
   throw new ArgumentOutOfRangeException("targetDatabase", Messages.NoDatabaseSpecified);
try
{
   this.ClearCaches(database);
}
catch (Exception ex)
{
   PublishingLog.Error(Messages.ErrorOccuredClearingTargetDataCache, ex);
   throw;
}

If you check Slot 2 logs, there may be error messages saying that the website is unable to find a database called web2.

In order to fix this problem, I would recommend patching configs on the second slot to add a database with name web2 and switch site configs to use web2 instead of web. Remember to check all places that rely on the database name: indexes, schedulers, etc.

5
  • 1
    Thanks Anna, this is exactly where I am heading. As I am in a multisite config, I was thinking of something like this for each site. <sites> <site name="website" set:database="web2" /> </sites>
    – Kode
    Commented Aug 31, 2023 at 17:13
  • 1
    @Kode yes, that should do it. Just make sure you have got all web2 indexes in configs on the second server. Commented Aug 31, 2023 at 17:20
  • 1
    Thank you, I definitely need to update the Solr pathing to hit the web2 index
    – Kode
    Commented Aug 31, 2023 at 17:23
  • 1
    Would I need to change the connectionStrings as well? Currently it is named web and points to the 2nd database... I get an error of not finding web2 with this config. Any issues adding web as the original string to the 1st database and then add web2 since my database config will set the database to read from web2?
    – Kode
    Commented Aug 31, 2023 at 17:40
  • 1
    @Kode good point, you have a couple of options: the easiest way is adding a connection string with name web2. Alternatively, you can specify connectionStringName to override the value that is taken from the database name by default. It looks similar to this: <database id="web2" ...> <param desc="name">$(id)</param> <connectionStringName>web</connectionStringName>... Commented Sep 1, 2023 at 7:54
1

To expand on my comment earlier, please confirm that all of your instances have a unique value for "InstanceName" in your configuration files. This is relevant because that value is combined with the database name to create a key in the properties table (i.e. WEB_EQSTAMP_YourInstanceName) that indicates when last event was processed. If incorrect it will not process events correctly. Check the properties table and ensure this timestamp matches the last event in the event queue.

Note: The stamp columm in event queue is in base 16. You can convert to base 10 by removing the first two chars (i.e. "0x" from 0x000000000028368F) and pasting into an online converter: Base 16 to Base 10

1
  • Thanks. I will confirm that (running multiple instances in Azure PaaS). Sitecore Support is guiding that I need to create a patch config that replaces every instance of the value “web” across the 2nd CD as my config above with the database set of web2 and setting of website to point to web2 does not seem enough
    – Kode
    Commented Sep 4, 2023 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.