When purging old item versions with the Remove-TcmItemsOldVersions Powershell cmdlet, you experience an error similar to the below:
Remove-TcmItemsOldVersions : The transaction has aborted. Transaction Timeout At line:1 char:1 + Remove-TcmItemsOldVersions -ContainerItemIds(Get-TcmRepository).Id -VersionsToKe ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Remove-TcmItemsOldVersions], FaultException`1 + FullyQualifiedErrorId : GeneralError,Tridion.ContentManager.Automation.Commands.RemoveTcmItemsOldVersionsCommandOr: Remove-TcmItemsOldVersions : The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '01:40:00'. At line:1 char:1 + Remove-TcmItemsOldVersions "tcm:0-16-1" -VersionsToKeep 5 -Recursive -TimeOut 10 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Remove-TcmItemsOldVersions], CommunicationException + FullyQualifiedErrorId : System.ServiceModel.CommunicationException,Tridion.ContentManager.Automation.Commands.RemoveTcmItemsOldVersionsCommand |
Before purging old item versions, can run below query against CM database to see how many item versions are being stored.
select i.publication_id,i.item_reference_id, i.Item_Type, count(i.item_reference_id) as NumbOfVersion, p.Title, pm.Path from items i left join publications p on i.Publication_id = p.Id left join item_references ir on ir.Id = i.Item_reference_id left join Organizational_Items oi on oi.Id = ir.Organizational_Item_Id left join Path_Mappings pm on pm.Organizational_Item_Id = ir.Organizational_Item_id and pm.PUBLICATION_ID = i.PUBLICATION_ID group by i.publication_id, i.item_reference_id, i.Item_type, p.Title, pm.Path having (count(i.item_reference_id) > 1) order by NumbOfVersion desc, i.Publication_Id, i.Item_Reference_id;Increase the CoreService timeouts and database query timeouts as per the below articles: In Tridion/Web, how to modify various settings to affect core service timeout With SDL Web 8.1/8.5, the script Remove-TcmItemsOldVersions has a long running query and times out If you still see timeouts, you can restrict the number of items to purge each time by using some of the other cmdlet options. To show the full list: Get-Help Remove-TcmItemsOldVersions -FullTry specifying a specific publication to purge from, keeping a larger number of versions and setting the MaxResolvedItemsCount (default is 100000). Also add the TimeOut value. E.g. Remove-TcmItemsOldVersions -ContainerItemIds "tcm:0-14-1" -VersionsToKeep 30 -Recursive -MaxResolvedItemsCount 10000 -TimeOut 900To loop through all publications, purging each one individually, use something like the below Powershell: Get-TcmRepository | ForEach-Object { Remove-TcmItemsOldVersions $_.Id -VersionsToKeep 30 -Recursive -TimeOut 900 }The output from each iteration of is the number of items purged. Add -Confirm:$false to turn off the prompts for each publication. |
The purge is taking a long time to complete and timeouts need to be increased |