Retention policy issue on Server 3.1.5

I am getting the follow error on Apply retention polcies on the server. It looks like a sql issue but not entirely sure where it is coming from. This is not on a deploy but rather from the server. Let me know if you need more information.

The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
System.Data.SqlClient.SqlException (0x80131904): The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at Octopus.Core.RelationalStorage.TransientFaultHandling.IDbCommandExtensions.<>c__DisplayClass5_0.<ExecuteReaderWithRetry>b__0() in Y:\work\refs\tags\3.1.5\source\Octopus.Core\RelationalStorage\TransientFaultHandling\IDbCommandExtensions.cs:line 67
   at Octopus.Shared.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) in Y:\work\refs\tags\3.1.5\source\Octopus.Shared\TransientFaultHandling\RetryPolicy.cs:line 215
   at Octopus.Core.RelationalStorage.RelationalTransaction.<Stream>d__23`1.MoveNext() in Y:\work\refs\tags\3.1.5\source\Octopus.Core\RelationalStorage\RelationalTransaction.cs:line 237
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at Octopus.Core.RelationalStorage.QueryBuilder`1.ToDictionary(Func`2 keySelector) in Y:\work\refs\tags\3.1.5\source\Octopus.Core\RelationalStorage\QueryBuilder.cs:line 123
   at Octopus.Server.Orchestration.Retention.ApplyRetentionPoliciesTaskController.ApplyRetentionPolicy(Lifecycle lifecycle, IList`1 projects, IList`1 releases) in Y:\work\refs\tags\3.1.5\source\Octopus.Server\Orchestration\Retention\ApplyRetentionPoliciesTaskController.cs:line 143
   at Octopus.Server.Orchestration.Retention.ApplyRetentionPoliciesTaskController.ApplyRetentionPolicy(IGrouping`2 policy) in Y:\work\refs\tags\3.1.5\source\Octopus.Server\Orchestration\Retention\ApplyRetentionPoliciesTaskController.cs:line 124
   at Octopus.Shared.Tasks.OctoThreadClosure`1.Execute() in Y:\work\refs\tags\3.1.5\source\Octopus.Shared\Tasks\OctoThreadClosure.cs:line 29
ClientConnectionId:18a16d3a-0b4e-41a6-9a25-5ef22003e99b
Octopus.Server version 3.1.5 (3.1.5+Branch.master.Sha.a3fb854d900077b8b028687f3a4ca01c59e84f56)

Hi Brent,

It looks like you’ve tripped over the same issue as http://help.octopusdeploy.com/discussions/problems/40307. We’ve raised https://github.com/OctopusDeploy/Issues/issues/2059 to fix this issue.

In the meantime, could you check how many Releases you have for that Project, you may be able to manually clean up enough to get automated retention policies working again. If there are too many Releases for a manual clean up you could write a quick script against the Octopus API using PowerShell to clean up the old Releases: https://dalmirogranias.wordpress.com/2014/09/19/using-octopus-client-library-with-powershell/

Hope that helps!
Mike

Michael,

Thanks sorry I did not see this issue. I will follow the github issue for a fix on this but it does not seem like its an issue which will corrupt data, just things will not get cleaned up at this time.

Thanks for pointing me in the right direction!

Hi Brent,

Thanks for getting back to me. You’re right, it’s not a dangerous bug, but it is annoying when retention policies are supposed to help you clean up, and the work around for the bug is to… clean up first, and then retention policies will be able to clean up for you…

Keep an eye on that GitHub Issue to see when the bug fix is released.

Happy Deployments!
Mike

Hi Brent,
Just an update to this issue. A fix for this bug has been made and it should be included in the 3.2.1 in the next day or two.
Please keep an eye out and give it a try once available. Hopefully it solves your issue.
Cheers,
Rob

Thanks!