A solution to the Links Database issue in Sitecore 9
In some cases, we have to set up our Content Management (CM) server as a standalone instance, which will still allow us to use the Content Delivery (CD) roles appropriately. An example of such case is when we try to run Processing, Reporting and Content Management role on the same instance in Sitecore 9 and the server role config with Content Management, Processing, Reporting is not working (see the details of the issue).
A solution to that issue is to set up a CM server with the standalone role. It works out most of the times, but in case you use Links Database on your project for some purposes (in our case we use it to pull related articles, for example), you will notice that references are missing on CD servers and your functionality will not work in the end.
We faced the issue twice and the reason, which caused it, is really simple, but not obvious. Let’s look at the patch settings in the Sitecore.config:
<sc.variable name="defaultLinkDatabaseConnectionStringName" value="core" /> <sc.variable name="defaultLinkDatabaseConnectionStringName" role:require="ContentDelivery or ContentManagement"> <patch:attribute name="value">web</patch:attribute> </sc.variable>
We can see that the path will be applied only for a CD or a CM role. In case we use the standalone role for CM server, the Core database will be used to store references between items. At the same time, the patch will be applied to the CD server and it means that the CD server will be expected to see references in the web database. So, the CM server writes the links into the Core database, while the CD server reads it from the web database…and here comes the issue.
To solve the issue we only need to update the patch:
<sc.variable name="defaultLinkDatabaseConnectionStringName" value="core" /> <sc.variable name="defaultLinkDatabaseConnectionStringName" role:require="ContentDelivery or ContentManagement or Standalone"> <patch:attribute name="value">web</patch:attribute> </sc.variable>
Or create our own patch file to avoid any changes in default Sitecore configuration files.