[SOLVED] Deleting old content versions of nodes re...
# help-with-umbraco
m
Hello, we are using Umbraco 10.7.0 and tried to clean old history of content nodes with the built-in scheduled task "ContentVersionCleanup". However this is resulting in an execution timeout. I guess because some nodes got 10.000 + different versions (due to a coding mistake in a custom scheduled task). We fixed the custom scheduled task to not save & publish some nodes every 5 minutes, but now we want to cleanup the old versions somehow. Since the built-in task won't work in this case, I tried to make a SQL script that deletes all old versions based on the built-in task (https://github.com/umbraco/Umbraco-CMS/blob/contrib/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs#L24). The custom SQL script is provided one screenshot that puts the result of the WHERE clause in a temporary table for reuse, and one screenshot with the actual DELETE statements. I do not know if this script is save to run as there are many relationships, and it's possible to miss out on some tables and leave old data without a pointer/index in the database. Especially I think these tables also might have some relationship with content versions, but did not see them in the built-in scheduled task: - cmsContentNu - umbracoContent - umbracoDocumentCultureVariation - umbracoLog - umbracoMediaVersion I am curious if someone else already made a similar script or if there is maybe a cleaner solution to solve this problem, like increasing the timeout period of deleting nodes. https://cdn.discordapp.com/attachments/1159425757811048468/1159425758087876618/Screenshot_1.png?ex=6530fa61&is=651e8561&hm=078fe3e9d4cd3ee530f834b958cef0aa4f40586f0f4be30dceb163e799dee981& https://cdn.discordapp.com/attachments/1159425757811048468/1159425758389870602/Screenshot_2.png?ex=6530fa61&is=651e8561&hm=574e8bcb7b448a506a3e555ba7a4df7c705d6227cd5e7bf162d348981fb4e709& https://cdn.discordapp.com/attachments/1159425757811048468/1159425758641520701/Screenshot_3.png?ex=6530fa61&is=651e8561&hm=dcdb97f428bb851a2a837c660de95974293d4d51af1429676778583599561a69& https://cdn.discordapp.com/attachments/1159425757811048468/1159425758847045652/Umbraco10DeleteContentVersionsScript.sql?ex=6530fa61&is=651e8561&hm=b16597a0446fb7d9e04a7142e5eda045e5e18bb8605eccb70bcc2668c7a5ecad&
This is now solved by disabling all scheduled tasks (ContentVersionCleanupPolicy, ScheduledRecordDeletion, and custom tasks). After that I deleted the TEMP folder and restarted the site. Cleaned the umbracoLog table, and deleted large json log files via Kudu. Now I could finally empty the recycle bin without getting timeout errors or lock errors. After this the site was running really smooth again, so I enabled the scheduled tasks again. 😃
2 Views