Monday, March 9, 2015

Cleanup OpenSource Powershell Script - "Delete files older than x-days" - can interfere with SDL Tridion transactions folder: How to avoid this?


In my last post, I talked about how the anti-virus scan can impact publishing and which folders to ensure to exclude from scanning. 

After that post, I came across another issue that showed me that not only anti-virus scanning is to be kept in mind when configuring Tridion servers.

I came then across an issue where the items suddenly remained in 'Ready for Transport' in the Publishing Queue and then noticed that the 'TRIDION_HOME\bin\transactions' folder was no longer a regular folder but instead turned into a flat file. 

After further investigation, it turned out that there was a daily scheduled task cleaning up the transactions folder. While this is a common and recommended practice to clean up old tridion files, this task was removing the transactions folder and causing this strange behavior.

The powershell script that this scheduled task was executing, is an open source powershell script that can be found in the following link:


 If you are making using of such script on your servers, it is important to keep in mind that, by default, this script handles folder deletion as follows:  

*Default mode, only delete folders that became empty after the script deleted all files in the folder, this includes the root folder.

The moment this script is running on your server, if there happens to be any activity in the transactions folder, this script will remove its content and also the transactions folder. 

At that moment, the items will then show in the Publishing Queue that they are ‘Ready for Transport’. In such situation, you might then restart your SDL Tridion Transport Service and notice that the items will still remain in the same state. If you inspect the ‘ TRIDION_HOME\bin’ folder, it might be showing the transactions as a flat file. Please note that this behavior will only happen if, at the time the script was executed the Transport was busy also processing items. 

To ensure that you don’t come across this issue, you will need to modify the script to include one of the following switches that are available:

* -NoFolder switch, no folders are deleted including the root folder.
* -CleanFolders switch, all empty folders in the path will be deleted, this however excludes the root folder.

As an example, you would then update your script to something similar to this:

# Cleaning Transactions folder
.\deleteold.ps1 -FolderPath "D:\Tridion\transactions" -FileAge 5 -log "D:\Tridion\log\cleanup" –autolog –NoFolder

Or

# Cleaning Transactions folder
.\deleteold.ps1 -FolderPath "D:\Tridion\transactions" -FileAge 5 -log "D:\Tridion\log\cleanup" –autolog –CleanFolders

After this change, your Transport Service will always happily process items!

Note: After reading this blog post, a customer reported that this issue can also happen when there are still files present in the transactions folder and not just when the folder is empty. Please keep also this in mind and ensure to implement the change above to completely avoid the issue also in the scenario that there are some old .state.xml files left in the transactions folder. 

No comments: