7

We are using the new Sitecore Publishing Service version 2 on one of our projects, but are running into a problem since it does not keep the descendants table up to date on the web database.

The documentation states: "The Publishing Service does not maintain the descendant table by default" but provides no guidance on how to change the configuration to make it update the descendants table.

What is the best way to keep the descendants table updated when using the publish service?

2

Maintaining the descendants table is supported by the Publishing Service, it's just not enabled by default, and not documented.

It's not enabled by default because it adds a performance cost to each publish, which scales with the size of the content tree, regardless of the size of the publish job. It's only required by the 'fast query' API, which is no longer a recommended practice and so very seldom used by 8.0+ sites.

The following configuration can be used to enable the descendants table support.

(Please see the Installation and Configuration guide for guidance on how to provide custom configuration files.)

<Settings>   
  <Sitecore>
    <Publishing>
      <Services>
        <PromotionCoordinator>
          <Options>
            <RebuildDescendantsTable>true</RebuildDescendantsTable>
          </Options>
        </PromotionCoordinator>
      </Services>
    </Publishing>   
  </Sitecore> 
</Settings>
  • This setting seems to be working, the publishing service is now keeping the descendants table updated. – S. Daugaard Jun 14 '17 at 14:23
2

For an Official Solution...Sitecore Support

The documentation that you are referring to is actually the KnowledgeBase article for "Known issues for Sitecore 8.2", and the statement that you quoted is actually an entry that lists this as a known issue for the Publishing Service in Sitecore 8.2:

The Publishing Service does not maintain the descendant table by default.

You should reach out to Sitecore Support for this issue. Since there is no reference number included with the entry, you should link them to the KB article and mention the quoted text to see if they can provide you with a workaround/patch.

Workaround Mentioned by @MarkCassidy:

As mentioned by Mark in the comments on this post, you could work around this issue by writing a handler for the publish:complete event that executes the database cleanup for the Web database. Note that this may or may not be the most desirable solution - I still recommend reaching out to Sitecore first, in case they have a more efficient patch.

What you would need is a patch-config, similar to the following:

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>     
    <events>     
        <event name="publish:complete">     
            <handler type="MyProject.EventHandlers.DatabaseCleanup, MyProject" method="OnPublishComplete" />     
        </event>      
    </events>     
</sitecore>
</configuration>

And then a class similar to the following:

namespace MyProject.EventHandlers
{
    public class DatabaseCleanup 
    {
        public void OnPublishComplete(object sender, EventArgs args)     
        {     
            var sitecoreArgs = args as Sitecore.Events.SitecoreEventArgs;     
            if (sitecoreArgs == null) 
            {
                return;
            }

            var publishingOptions = sitecoreArgs.Parameters[0] as IEnumerable<DistributedPublishOptions>;
            if (publishingOptions == null) 
            {
                return;
            }

            var targetDatabases = publishingOptions
                .Select(option => option.TargetDatabaseName);
            foreach(var databaseName in targetDatabases) 
            {
                var database = Sitecore.Configuration.Database.GetDatabase(databaseName);
                database?.CleanupDatabase();
            }
        }
    }
}
  • Isn't this the same descendants table as used by Fast Query? "Note If the FastQueryDescendantsDisabled setting, in the web.config file, is set to true and then changed back to false, you must rebuild the Descendents table. To rebuild the Descendents table, click Sitecore, Control Panel, Databases, Clean Up Database and run the Clean Up Database wizard." – Mark Cassidy Jun 13 '17 at 16:37
  • Yes, and that solution would work and the clean-up command could even be invoked programmatically. However since this is a known issue without an official, publicly documented solution, I think the first step should be to reach out to Sitecore for a patch, as there may be a far more efficient way of executing the rebuild without having to invoke the command on publish:complete. – Zachary Kniebel Jun 13 '17 at 16:44
  • Thanks guys - this was going to be our backup solution but I wanted to see if there was an official way of doing it before implementing it. I've submitted a ticket to Sitecore support, but have been waiting several days for a response. – S. Daugaard Jun 13 '17 at 17:02
  • @MarkCassidy for thoroughness, I added some sample code for the solution that you mentioned, but I do still believe that the issue should be raised to Sitecore support before going into production. ;) – Zachary Kniebel Jun 13 '17 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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