meta data for this page
Common reasons of synchronisation failures
A common complain of the users which edit content using the CMS Cockpit is that the synchronisation stops working quite often. During September and October 2015 I solved around 37 cases and found 16 different causes of sync errors. This is a summary of the categories of errors and tips or measures to prevent them.
Hybris usually only reports “An exception occurred during synchronization” in the logs, so you have to further analyse that the cause of the failure is.
Procedure to find out why the synchronization isn't working
- Check the log files. The synchronisation code logs little information but by reading the log you get how the synchronization was triggered.
- Go to Backoffice > System > Types
- Look for the type CatalogVersionSyncCronJob
- Open the type
- Click two times on the arrow on the upper right corner to search instances
- In the field Job select the catalogue which is failing
- Open the last cronjob with has last result error or system error.
- Click on the log tab
- Download and check the last log file if it exists.
- Click on the administration tab
- Download the dump medias
- The first one contains the list of items which were schedule for the synchronisation
- The second and last ones have the same information. It is the list of PKs of the items which couldn't be synchronized with the following columns: PK of the source object, PK of the target object and PK of the synctimestamp.
- For each source PK use HAC > Platform > PK Analyser to get its type
- Now the cause of the error in the synchronisation must be found:
- SQL queries may show rows with nulls on mandatory fields or pks to objects which doesn't exist any more.
- With SQL you can also check if two components, medias or content slots share the same uid and are on the same catalogue version.
- The catalogue version of the objects referenced by these items may be wrong
- There is an old object with the same UID in the online catalog version and they have different types.
- The SyncJob will only synchronized objects of the types which are in his configuration.
Disadvantages of the legacy mode
- It can synchronize components with errors like missing values in mandatory fields. It allows the developers to ignore data errors in the CMS catalogue.
- It can end successfully without synchronizing the navigation nodes and entries. The cause of this bug is still unknown.
- The legacy mode is deactivated by default. The setting is called synchronization.legacy.mode
Errors Categories
Category | Causes | Countermeasures | Will happen again? |
---|---|---|---|
The CatalogVersionSyncCronJob and CatalogVersionSyncJob don't synchronize any items after the first execution. | Unknown. The cronjob has dump medias after the first successfull execution. | - Use each CatalogVersionSyncJob only once. Create them with impex, run them with a groovy script and remove them at the end with impex. You can use the Areco deployment manager for this task - The business and the developers must use SmartEdit or WCMS to sync catalogues. Don't use hmc. | No |
Duplicate CMS1) Items (same UID in the a Catalogue Version) | Unknown | - Creation of unique indexes in the tables with CMS items. Please read the detailed explanation below. | No |
Many ContentSlotsForPage or ContentSlotsForTemplate for the same position, slot and page | Rename of the content slots for Pages/Templates without removing the old ones | - Impex Scripts: Be more careful when renaming content slots and content slots for pages or templates | Ja |
Mandatory field with a null value or an invalid PK | - Unlink of the CMS Navigation Entries from the navigation nodes - Bugs in the Impex Scripts which lead to null values in the items - Removal of CMS Items, which where changed after the last synchronization, in the WCMS like the removal of a page after working with its content slots. | - To synchronize the catalogue before an user removes a page, a navigation node or another CMS item. This reduces the possibility of a sync error. - Use of removal interceptors to prevent usual cases when it is possible - Impex Scripts: Be more careful when removing CMS Items which may be referenced be another one, for example, content slots are referenced by content slots for pages or for templates | Ja |
Edition mistakes | - Reference to an object which is in a wrong catalogue - Circular References between catalogues | - Limit the access to the catalogues. If the user can't see other catalogues, he can't choose the wrong one - Training of the users to identify this error before calling the developers | Ja |
Type change of an existent CMS Item | - The same UID points to a CMS components of different types in the source and target catalogues. For example: The carousel components where created and synchronized. Then the same UIDs was used by the new carousels with popularity components. The synchronization will fail because the UID points to components with two different types. | - Remove the components in the target version and synchronize again - Don't reuse the UID. A new component type means new UIDs | Nein |
Examples of edition mistakes and empty mandatory fields
The main causes are mandatory fields with null or invalid PKs values and CMS items using with a wrong catalogue version. These errors may be originated on these cases:
- WCMS
- Removal of a page, a CMS link component or media linked to a CMS Navigation Entry. A remove interceptor can be written to prevent the removal of the item if it is associated to a navigation entry.
- Unlink a CMS Navigation Entry from a Navigation Node. The WCMS doesn't delete the navigation entry.
- Removal of a page without removing the contentSlotForPages after editing them. A remove interceptor can prevent this situation.
- Add a reference in CMS component to a product within a CMS catalogue version and the sync job of it is configured to synchronize only CMS medias, relations and items.
- Add a reference to a item in another catalogue which has references to the actual one. This will generate a circular reference between the catalogues. For example: A restrictions in an old catalogue is used by CMS components in the new catalogue.
- Remove a page and create a new page with the same ID without synchronising. After the removal of the page, the catalogue must be synchronized.
- A CMS component or a navigation entry references a media in the same catalogue but the sync job isn't configured to synchronized this type.
- Impex Errors
- Removal of a contentslot without removing all the associated contentSlotForTemplate and contentSlotForPage. An sync error will only be triggered if the second objects were modified or a full synchronisation of the catalogue is done.
In every case the item with the error must have been modified after the last synchronization. If it isn't, the sync process is going to ignore it unless you select “force update” on the synchronisation wizard in hMC. To teach the WCMS users to synchronize any change before removing a component, page or navigation node and to remove access to other catalogues reduces the occurrence of the above cases.
Useful tips to troubleshoot exceptions during the creation/copy of the target sync-item
If you get an error similar to:
d.h.p.c.j.s.AbstractItemCopyContext : An exception occured during synchronization for item: 8796388590637 of type: Content Slot-Beziehung für eine Seitenvorlage
Put a breakpoint inside de.hybris.platform.catalog.jalo.synchronization.GenericCatalogCopyContext#copy(de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreator, de.hybris.platform.jalo.Item, de.hybris.platform.jalo.Item, de.hybris.platform.catalog.jalo.ItemSyncTimestamp) to find out what exception was thrown.
The cause are usually validate interceptors or after save listeners which prevent creating the target hybris item.
You can enable logging of stacktraces in the sync jobs by setting synchronization.itemcopycreator.stacktraces to true. You need log level INFO or finer at the Logger de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreator. Please see https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/aa417173fe4a4ba5a473c93eb730a417/1c60bf4de9bf4ada99b587f569bbb9ec.html?locale=en-US
Userful flexible search queries
Find navigation entries with invalid or missing PKs
select {c.id} catalog, {cv.version} catalogVersion, {ne.uid} UIDEntry, {ne.pk} pkEntry from {CMSNavigationEntry as ne JOIN CatalogVersion as cv ON {cv.pk} = {ne.catalogVersion} JOIN Catalog as c ON {c.pk} = {cv.catalog} } where {ne.item} is null or NOT EXISTS ({{ SELECT 1 FROM {CMSItem AS i} WHERE {i:pk} = {ne.item} }})
Duplicate CMS Items
In one project the synchronisation created duplicate same code or uid medias, contentslots and navigation nodes. Although the multi-threading in the synchronization was turned off2), the system kept generating duplicate medias. The cause of the error is still unknown but unique indexes for the column catalogVersion and code/uid on the tables medias, contentslot, cmscomponent, cmsnavigationnode, cmsnavigationentry, slotsfortemplate and slotsforpage solved the issue. After the creation of the index no error message or stack trace is shown in the logs, so further investigation of the issue couldn't be done.
Tips
- If you a validate interceptor is throwing exceptions during the synchronization, you can turn off its validation by checking if the following attribute is true:
this.getSessionService().getCurrentSession().getAttribute("catalog.sync.active");
–Tested on SAP Hybris 2005 and 5.6
Discussion
you can enable logging of stacktraces in sync jobs by setting synchronization.itemcopycreator.stacktraces to true (and you need log level INFO or finer at the Logger de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreator).
See https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD/aa417173fe4a4ba5a473c93eb730a417/1c60bf4de9bf4ada99b587f569bbb9ec.html?locale=en-US
I updated the page! Thanks Johannes!