Issues
Issues copied to clipboard
DataMigrationCoordinationJob Must declare the scalar variable "@BatchSize"
Severity
No response
Version
Earliest reported was Windowx x64 2024.4.7115 still happening in 2025.2.13043
Latest Version
None
What happened?
Investigating OctopusServer log. Saw exception below. Running Windows x64, SQL Server database using a case sensitive collation Latin1_General_BIN2.
Reproduction
- Start Octopus Service
- Investigate Octopus Server log
Error and Stacktrace
2025-09-02 00:00:58.5798 2924 35 ERROR Error executing job "DataMigrationCoordinationJob"
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable "@BatchSize".
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at Octopus.Core.RelationalStorage.RawRelationalTransaction.ExecuteReader(String query, CommandParameterValues args, Nullable`1 commandTimeout) in ./source/Octopus.Core/RelationalStorage/RawRelationalTransaction.cs:line 200
at Octopus.Core.Features.DataMigrations.DedupeBuildInformationMigration.GetDeploymentIdsAndDelayForBatch(DedupeBuildInformationMigrationState state) in ./source/Octopus.Core/Features/DataMigrations/DedupeBuildInformationMigration.cs:line 220
at Octopus.Core.Features.DataMigrations.DedupeBuildInformationMigration.Execute(DedupeBuildInformationMigrationState state) in ./source/Octopus.Core/Features/DataMigrations/DedupeBuildInformationMigration.cs:line 89
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
ClientConnectionId:ac6b5f1f-4111-41b2-8f08-37ccd04576c9
Error Number:137,State:2,Class:15
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Octopus.Core.Features.DataMigrations.MigrationExecutor.Execute(DataMigrationState state) in ./source/Octopus.Core/Features/DataMigrations/MigrationExecutor.cs:line 28
at Octopus.Server.ScheduledJobs.Jobs.DataMigrationCoordinationJob.ExecuteMigration(DataMigrationState migrationState) in ./source/Octopus.Server/ScheduledJobs/Jobs/DataMigrationCoordinationJob.cs:line 92
at Octopus.Server.ScheduledJobs.Jobs.DataMigrationCoordinationJob.Trigger(CancellationToken cancellationToken) in ./source/Octopus.Server/ScheduledJobs/Jobs/DataMigrationCoordinationJob.cs:line 59
at Octopus.Core.Features.ScheduledJobs.Scheduling.JobRunner.<>c__DisplayClass4_0.<<Run>b__1>d.MoveNext() in ./source/Octopus.Core/Features/ScheduledJobs/Scheduling/JobRunner.cs:line 72
--- End of stack trace from previous location ---
at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExecutor.<>c__DisplayClass3_0.<<Execute>b__0>d.MoveNext() in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWorkExecutor.cs:line 35
--- End of stack trace from previous location ---
at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExtensionMethods.Do(IUnitOfWork unitOfWork, Func`1 action, CancellationToken cancellationToken, String name) in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWorkExtensionMethods.cs:line 53
at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExtensionMethods.Do(IUnitOfWork unitOfWork, Func`1 action, CancellationToken cancellationToken, String name) in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWorkExtensionMethods.cs:line 59
at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExecutor.Execute(Type rawType, Func`3 action, CancellationToken cancellationToken, String name) in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWorkExecutor.cs:line 31
at Octopus.Core.Infrastructure.UnitsOfWork.UnitOfWorkExecutor.Execute(Type rawType, Func`3 action, CancellationToken cancellationToken, String name) in ./source/Octopus.Core/Infrastructure/UnitsOfWork/UnitOfWorkExecutor.cs:line 31
at Octopus.Core.Features.ScheduledJobs.Scheduling.JobRunner.Run(JobDefinition definition, CancellationToken cancellationToken) in ./source/Octopus.Core/Features/ScheduledJobs/Scheduling/JobRunner.cs:line 50
More Information
No response
Workaround
No response