[DBCleaner] Error application DB Cleaner

Forge Component
Published on 2018-11-23 by Johan den Ouden
38 votes
Published on 2018-11-23 by Johan den Ouden
The support of OS suggest the implementation of the application DB Cleaner to delete old Espaces however application generates many errors of this type:
The DELETE statement conflicted with the REFERENCE constraint "OSFRK_ossys_App_Version_Module_Versi_OSSYS_ESPACE_VERSION_ESPACE_VERSION_ID". The conflict occurred in database "Outsystems" table "dbo.OSSYS_APP_VERSION_MODULE_VERSI" column 'ESPACE_VERSION_ID'. The statement Has Been terminated.
I tried to delete old espaces for 16 months.
This problem may be related to the LifeTime?
Yes, I believe it is.

Currently DBCleaner does not yet use the DBCleaner_API to list the available modules for deletion. You can check it's code.

It performs a few queries to try and determine what it can delete, but there are some internal entities to which DBCleaner does not have access to, and thus cannot take into consideration.

These errors are nothing to worry about. It's the system simply telling you you can't delete that module version. DBCleaner is still deleting as much as it can.

I'm planning on using the DBCleaner_API soon to overcome this limitation and be able to list precisely what module versions will be deleted. (note that DBCleaner component exists for more than the DBCleaner_API and also that it is available for versions which don't support DBCleaner_API)
Sorry, not mentioned that,
At the end of this process (and the successive errors) the application does not delete the old espaces.
Then, most likely, you only have old eSpace versions that can't be deleted.

Do you see any old eSpace versions to delete in ServiceCenter?
Using the Service Center - Factory> Espaces> Check eSpace Old Versions to Delete
The old espaces are deleted.
But it is a very slow task, so is necessary use this application but at the end of this process the application not deleted the old espaces.
I experience exact the same problem:

"Cannot delete or update a parent row: a foreign key constraint fails (`outsystems`.`ossys_espace_version`, CONSTRAINT `OSFRK_OSSYS_ESPACE_VERSION_OSSYS_PUBLISHING_PUBLISHING_ID` FOREIGN KEY (`PUBLISHING_ID`) REFERENCES `ossys_publishing` (`ID`))"

When deleting older versions of eSpaces through ServiceCenter it succeeds... Only 100 records at the time.. Very slow process.. Is it possible to have a solution on this topic?

After some work i have the following results:

When using the dbcleaner_API function "ModuleVersion_Delete" which was feeded using the "ModuleVersion_ListOldest" he only 4 versions of 1 module... (There are currently 5400 versions of a totall of 165 modules (including deleted).

When using service center option "Check Old eSpace Versions to Delete" the server deletes all the eSpace versions only 100 versions at the time... What is the difference between those functions and why can the eSpace cleanup tool delete the older versions 'while the dbcleaner_api can't?
Peter, it's weird that you're getting that error when attempting to delete. From what I can see the reference to ossys_espace_version from ossys_publishing has a DELETE rule, so the entry should be deleted, not hit a reference issue.

In any case, DBCleaner (this component) does not use the DBCleaner API to delete eSpace versions. It was created prior to this functionality and since it would not be easy to provide the same functionality (performance and an estimate of the space to be freed) using the API I have not yet migrated it.

As I have explained before, DBCleaner may list more espace versions than those it can actually delete. This happens because there is some data that is kept in private tables which are not accessible, and therefore cannot be taken into consideration. It will still try to delete all it can delete. The errors you see are informational only so you know why some of them weren't deleted. The errors are skipped and do not abort the process.

Service Center's functionality to delete old espace versions should delete about the same as DBCleaner_API. If this is not the case, I suggest you contact OutSystems Support in order to further troubleshoot. Would you like me to create a support case on your behalf for followup ?
Hi Ricardo,

Thanks for your fast reply. Can you create a support case on my behalf (my company)? That would be great because you can probably describe it in a better way.

We noticed that Lifetime also locks versions on a server when tagged in lifetime. This sound logical, but is it also possible (in an easy way) to remove old tags from lifetime and to "release" the older espace versions to get deleted by the dbcleaner espace?