"Apply retention policies" scheduled task fail because "too many parameters"

Hi,

After upgrading from 2.6.5 to 3.2.0, the scheduled “Apply retention policies” task fails for certain Lifecycles. The Lifecycles mostly have “keep releases 365 days” and 5 latest packages on target servers.

Ex:

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.2.0\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.2.0\source\Octopus.Shared\TransientFaultHandling\RetryPolicy.cs:line 215
   at Octopus.Core.RelationalStorage.RelationalTransaction.<Stream>d__23`1.MoveNext() in Y:\work\refs\tags\3.2.0\source\Octopus.Core\RelationalStorage\RelationalTransaction.cs:line 237
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Octopus.Server.Orchestration.Retention.ApplyRetentionPoliciesTaskController.ApplyRetentionPolicy(Lifecycle lifecycle, IList`1 lifecycleScopes, IList`1 releases) in Y:\work\refs\tags\3.2.0\source\Octopus.Server\Orchestration\Retention\ApplyRetentionPoliciesTaskController.cs:line 138
   at Octopus.Server.Orchestration.Retention.ApplyRetentionPoliciesTaskController.ApplyRetentionPolicy(IGrouping`2 policy) in Y:\work\refs\tags\3.2.0\source\Octopus.Server\Orchestration\Retention\ApplyRetentionPoliciesTaskController.cs:line 123
   at Octopus.Shared.Tasks.OctoThreadClosure`1.Execute() in Y:\work\refs\tags\3.2.0\source\Octopus.Shared\Tasks\OctoThreadClosure.cs:line 29
ClientConnectionId:8b3012b5-584c-4da4-86af-a7d56b673c5f
Error Number:8003,State:1,Class:16
Octopus.Server version 3.2.0 (3.2.0+Branch.master.Sha.391e7e2a161abf18405930022a65470fbfeb195d)

I tried reducing one of the Lifecycles to keep releases 100 days but I came up with the same result. But maybe that just adds to the parameters?

Maybe I should try to create a new Lifecycle with the same rules and split the projects on to these two Lifecycles. Maybe that will decrease the number of parameters?

Any tips?

Hi Erik,

Thanks for reaching out. We fixed this issue in 3.2.1 https://github.com/OctopusDeploy/Issues/issues/2059

Please try to update to the latest version of Octopus (currently 3.2.3) to get this fix.

Regards,

Dalmiro

Yep, a coworker just sent me that. My googling skills seems to be lacking :wink:

Thanks, I will try to upgrade