Apply retention policies Fails If a Release Has Hundreds of Deployments

The Octopus server task “Apply Retention Policies” is failing with the error:
The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.

The issue appears to be caused by one of our projects that has a release with 525 deployments. Using the API method referenced in Github issue #1039 I manually deleted a few of the release’s deployments and re-running the “Apply Retention Policies” succeeded.

Here’s a few details I forgot to include in the original post, sorry.

This issue is occurring on Octopus 3.2.17.

In the original comment I misrepresented the deployment history, the release has been deployed 525 times to 5 environments for a total history of 2,625 deployments tied to the same release. After deleting 3 deployments via the API the “Apply Retention Policies” server task stopped failing.

Hi Forrest,

Thanks for getting in touch. This is a sql server error caused by passing too many parameters in a database statement. I took an initial look at the retention policy code but it wasn’t clear where it failed. Can you attach the raw task log for the ? The following URL has more information on this. http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

Also, is this the first time you’ve turned on retention policies? I’m guessing this a bug but I should be able to confirm it after I see the raw log file.

Looking forward to your reply.

Thanks

Rob

Hi Rob,

Thank you for the quick response. We have had retention policies enabled since initial install, though this is the first time this particular error has been encountered.

We have a pipeline in Go that deploys an Octopus project every hour that only creates a new Octopus release when changes have been pushed to Go, otherwise it uses the last release from Octopus. In this instance there hadn’t been changes pushed to Go in ~3 weeks so it was calling the same Octopus release which caused the huge deployment history. We are looking at forcing Go to create new releases at certain intervals to avoid this issue as an interim solution.

As for the raw task log, it looks like we only have the last 4 instances of the “Apply Retention Policies” task in Octopus’s task log so I am unable to find the full data there. I do have the error trace that was being thrown though, hopefully it contains enough info to be helpful:

14:00:23.613 Error from Octopus server (HTTP 500): Octopus Server returned an error: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
14:00:23.613 Server exception: 
14:00:23.613 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.
14:00:23.613    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
14:00:23.613    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
14:00:23.613    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
14:00:23.613    at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
14:00:23.613    at System.Data.SqlClient.SqlDataReader.get_MetaData()
14:00:23.613    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
14:00:23.613    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
14:00:23.613    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
14:00:23.613    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
14:00:23.613    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
14:00:23.613    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
14:00:23.613    at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
14:00:23.613    at Octopus.Core.RelationalStorage.TransientFaultHandling.IDbCommandExtensions.<>c__DisplayClass5_0.<ExecuteReaderWithRetry>b__0() in Y:\work\refs\tags\3.2.17\source\Octopus.Core\RelationalStorage\TransientFaultHandling\IDbCommandExtensions.cs:line 67
14:00:23.613    at Octopus.Shared.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func) in Y:\work\refs\tags\3.2.17\source\Octopus.Shared\TransientFaultHandling\RetryPolicy.cs:line 215
14:00:23.613    at Octopus.Core.RelationalStorage.RelationalTransaction.<Stream>d__24`1.MoveNext() in Y:\work\refs\tags\3.2.17\source\Octopus.Core\RelationalStorage\RelationalTransaction.cs:line 241
14:00:23.613    at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
14:00:23.613    at System.Linq.Enumerable.ToDictionary[TSource,TKey](IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
14:00:23.613    at Octopus.Core.RelationalStorage.QueryBuilder`1.ToDictionary(Func`2 keySelector) in Y:\work\refs\tags\3.2.17\source\Octopus.Core\RelationalStorage\QueryBuilder.cs:line 138
14:00:23.613    at Octopus.Server.Web.Api.Actions.DeploymentTemplateAction.Execute() in Y:\work\refs\tags\3.2.17\source\Octopus.Server\Web\Api\Actions\DeploymentTemplateAction.cs:line 58
14:00:23.613    at Octopus.Server.Web.Infrastructure.Api.Responder`1.Respond(TDescriptor options, NancyContext context) in Y:\work\refs\tags\3.2.17\source\Octopus.Server\Web\Infrastructure\Api\Responder.cs:line 162
14:00:23.613    at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
14:00:23.613    at CallSite.Target(Closure , CallSite , Object , Object , NancyContext )
14:00:23.613    at Octopus.Server.Web.Api.OctopusRestApiModule.<>c__DisplayClass0_0.<.ctor>b__0(Object o) in Y:\work\refs\tags\3.2.17\source\Octopus.Server\Web\Api\OctopusRestApiModule.cs:line 46
14:00:23.613    at CallSite.Target(Closure , CallSite , Func`2 , Object )
14:00:23.613    at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)

Hi Forrest,

Thanks for the reply. I did some digging and this was definitely a bug. The good news is that it was fixed in Octopus 3.2.21 so if you upgrade to it or a newer version, the issue should go away. :slight_smile:

Hope that helps!

Rob

Hello Rob,

Thanks for getting an answer on this so quickly. Coincidentally we already have an upgrade to 3.3.22 scheduled for the 22nd of this month, so that’s good to hear it’s been resolved.

Thanks again!

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.