Resolution
This issue usually occurs when administrators first adjust their Default Retention policies. We recommend following our general best practices. Depending on the time period between the default policy and the implementation of a personalized policy, it's best to start as far out as you can and gradually scale back to reduce strain on Octopus and SQL Server.
Scope: when this is the right article
If your Self-Hosted Octopus Server is maxing out your CPU and memory utilization, impacting production or crashing while applying your retention policies, this is the right article for you.
Cause
During the initial swap between the Default Policy and a personalized Retention Policy, most people will select their intended policy, which will prune significantly more items than a regular retention run would. This can also occur as a scaling issue if the number of items to be pruned within a set period has grown exponentially over time.
Diagnosis and fix
Scenario 1: This is the first time running retention, or there's a dramatic adjustment of retention.
General Recommendations
-
Adjust your Retention Policy down slowly over a period of time if you're seeing a significant performance impact. For example, if you have a year built up. Start small. Set it to 51 weeks instead of 11 months of retention. Then evaluate from there and increment it appropriately.
-
These Tasks run every four hours or so as a scheduled task. You can run them immediately if needed, but it's best to run the initial retention after shifting from your default Retention Policy schedule during off hours.
-
If the issue still exists after the above, you can scale up the server resources temporarily to deal with the initial Retention Tasks, then scale back down to what it was beforehand when retention is under control.
Scenario 2: This is happening well after implementing a new Retention Schedule
General Recommendations
-
Review your existing SQL Maintenance plans and existing jobs relating to that; we have some general recommendations on that here.
-
If you're running your Octopus Server and your SQL Server on the same VM or Server, you might need to separate them to reduce the number of factors that could impact performance during retention.
-
If all else fails, your SQL Server might be under-provisioned for your use case, especially if you're scaling significantly. Please review our scaling guidelines and open a support ticket if this behavior continues after we've made our recommendations.
Verify
You should be able to verify if the recommendations in this article work properly by monitoring your system resource utilization during retention tasks. If it's under control, it should no longer impact you between retention tasks.