Activating Data Hub Database Cleanup
Over time, a Data Hub database accumulates database records that are used for auditing, but as these records accumulate, they can also affect performance. The following document describes these records and which database tables are affected. Additionally, privacy rules can necessitate the ability to permanently delete consumer data such as orders and personally identifiable information. Database cleanup allows you to remove data related to these situations.
Prerequisites: For additional background or context regarding the following material, see Item Statuses.
When a Data Hub instance has been running for a long time, too many audit records accumulate in the Data Hub database. These records do affect performance. If not needed in the active Data Hub database, the historical auditing database records can be migrated to an archive database before elimination. They can also be eliminated without affecting the current state of Data Hub. These operations can be performed even when there are processes currently being performed by Data Hub on the database. The only consequence is that removing the records also removes the audit history for the records. The audit records show how and when they have been imported, composed, and published.
| Item Type | Table Name | Status Code for Items to be Deleted |
|---|---|---|
| Raw | RawItem | PROCESSED |
| Canonical | CanonicalItem | ARCHIVED |
| CanItemPubStatus |
These records have corresponding records in CanonicalItem. After removing the CanonicalItem record, its corresponding record can be removed from this table. |
|
|
If there are many successfully published canonical items in your Data Hub database, performance is affected. Set the property datahub.cleanup.publisheditems.enabled to true in your local.properties file. The property configures the datahub-cleanup extension to delete them. |
||
| TargetItem | TargetItem |
Given the targetsystempublication field refers to an entry in the TargetSystemPub table. Given the status field of that entry does not equal "IN_PROGRESS". The record can be removed. |
| CanItemPubStatusErrors | To delete any of these records, the targetsystempublication field must refer to an entry in the TargetSystemPub table where the status field does not equal "IN_PROGRESS". | |
| PublicationError |
Using Data Hub's Built-In Extension
The datahub-cleanup extension is deployed with the Data Hub WAR file.
- All raw items after they are processed in a composition
- All archived canonical items and their associated publication errors and status after a composition
- All target items after they are finished being used during a publication
datahub.cleanup.rawitem.enabled=true datahub.cleanup.canonicalitem.enabled=true datahub.cleanup.targetitem.enabled=true datahub.cleanup.publisheditems.enabled=true
Data Hub is shipped with these property values set to false.
Defining the Cleanup Batch Size
The datahub-cleanup extension processes all audit item deletes. The extension is triggered by an event and does its work in batches. The split of one large transaction into multiple smaller batches comes at the cost of total time for deletion. However, it gives the benefit of a more responsive and robust system. It also avoids potential issues with limitations certain databases may impose on the number of unique record IDs included in the IN clause of a query. For example, with Oracle, this number is limited to 1000.
The property datahub.sql.maxUpdateBatchSize defines the batch size. Set it to a reasonable value. n is the number of database records deleted in a single query. This property can be set in your local.properties file.
datahub.sql.maxUpdateBatchSize=500
If not explicitly specified, the default batch size is 1000 - the Oracle maximum. You can set the default batch size to any positive integer, but it cannot be set to a negative value.
Defining Canonical Item Cleanup Delay Times
When Data Hub publishes, it gathers data from two groups:
- all the new canonical items
- all canonical items that have previously failed to publish but have not reached their max retry limit
All of these canonical items in the pool are processed with the publication. The publication comprises of one or more publication actions. If there is a maximum publication action size, then the publication action is limited to that number of items. Whatever the number of publication actions used to publish all items, Data Hub creates them and queues them. One set of input data has the possibility of being split across several publication actions, because items are not preassigned to specific publication actions.
The cleanup extension is required for any Data Hub installation, because it has a powerful, positive impact on performance. However, if it is misconfigured, it can have negative impacts. You use the following two timeout properties to configure it. The two timeout properties described in the following are critical for a proper configuration. The properties must be in your local.properties file at Data Hub startup. If you activate the cleanup extension without specifying a value for these properties, they each default to 12 hours.
- datahub.cleanup.canonicalitem.time.delay – Set the property to a time beyond the time of the longest running publication. The value is usually tuned to something significantly larger than the longest running publication. Such a tuning accounts for spikes in data loads, increased volume over time, and so on. The time value is provided in whole seconds.
datahub.cleanup.canonicalitem.time.delay=43200
- datahub.cleanup.publisheditems.time.delay – Set the property to a time beyond the longest throughput time of any related and/or dependent items. For example, assume that the Customer and Address items are loaded independently, so they may be sent to a target system across two publications. Tune the datahub.cleanup.publisheditems.time.delay property, so that these items are still present during the second publication. The time value is provided in whole seconds.
datahub.cleanup.publisheditems.time.delay=43200
Excluding Certain Types from Cleanup
In some cases, you might want to exclude some canonical item types from deletion by the cleanup extension. There are no rules about which data you should exclude from cleanup. Whether you exclude items depends on your use of the data. For example, you can exclude data that you need to reuse such as configuration data, lookup data, or sales area data. You should exclude any data that is functionally required to be permanently retained in Data Hub. For example, CanonicalAttributeCategoryRelation.
To exclude items, use the property datahub.cleanup.publisheditems.excluded.types. This property takes a comma-separated list of canonical item types and excludes them from the published item cleanup routine. For example:
datahub.cleanup.publisheditems.excluded.types=CanonicalProduct,CanonicalAttributeCategoryRelationPerformance is affected when a high volume of successfully published canonical items are in your Data Hub database. To improve performance, the datahub-cleanup extension can be activated to delete successfully published canonical items. However, for out-of-the-box implementations, for example, when replicating SAP product and customer data, some canonical item types are required for the subsequent publications to be completed successfully. The following canonical items should not be cleaned up:
- CanonicalAttribute
- CanonicalCategoryProduct
- CanonicalProductTax
- CanonicalProduct
- CanonicalProductSales
- CanonicalProductUnit
- CanonicalParty
- CanonicalAddress
- CanonicalOrder