Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must declare the scalar variable "@initialVersion". #63

Closed
yreynhout opened this issue Apr 11, 2011 · 4 comments
Closed

Must declare the scalar variable "@initialVersion". #63

yreynhout opened this issue Apr 11, 2011 · 4 comments

Comments

@yreynhout
Copy link

I was trying to execute a command to create a new AR.

From peeking at the log of MsSqlServerEventStore I think it was probably broken by a merge/refactor between pwistrand's fix for deadlocks - which introduces this new variable - and aweiker's refactoring/cleanup:
699b665#Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs
9fdb026#Framework/src/Ncqrs/Eventing/Storage/SQL/MsSqlServerEventStore.cs

StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
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)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.UpdateEventSourceVersion(Guid eventSourceId, Int64 newVersion, SqlTransaction transaction) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Eventing\Storage\SQL\MsSqlServerEventStore.cs:line 425
at Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.StoreEventsFromSource(Guid eventSourceId, Int64 eventSourceVersion, IEnumerable1 events, SqlTransaction transaction) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Eventing\Storage\SQL\MsSqlServerEventStore.cs:line 530 at Ncqrs.Eventing.Storage.SQL.MsSqlServerEventStore.Store(UncommittedEventStream eventStream) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Eventing\Storage\SQL\MsSqlServerEventStore.cs:line 340 at Ncqrs.Domain.UnitOfWork.Accept() in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Domain\UnitOfWork.cs:line 91 at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.UoWMappedCommandExecutorCallbacks.ExecuteActionCreatingNewInstance(Func2 action) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 49
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootConstructorAttributeHandler.<>c__DisplayClass3.b__2() in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootConstructorAttributeHandler.cs:line 22
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.MapsToAggregateRootConstructorAttributeHandler.Map(MapsToAggregateRootConstructorAttribute attribute, ICommand command, IMappedCommandExecutor executor) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\MapsToAggregateRootConstructorAttributeHandler.cs:line 31
at CallSite.Target(Closure , CallSite , Object , Object , ICommand , IMappedCommandExecutor )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Ncqrs.Commanding.CommandExecution.Mapping.Attributes.AttributeBasedCommandMapper.Map(ICommand command, IMappedCommandExecutor executor) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\Attributes\AttributeBasedCommandMapper.cs:line 59
at Ncqrs.Commanding.CommandExecution.Mapping.UoWMappedCommandExecutor.ExecuteInContext(IUnitOfWorkContext context, ICommand command) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\Mapping\UoWMappedCommandExecutor.cs:line 17
at Ncqrs.Commanding.CommandExecution.CommandExecutorBase1.Execute(TCommand command) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\CommandExecution\CommandExecutorBase.cs:line 53 at Ncqrs.Commanding.ServiceModel.CommandService.<>c__DisplayClass91.b__8(ICommand cmd) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\ServiceModel\CommandService.cs:line 74
at Ncqrs.Commanding.ServiceModel.CommandService.Execute(ICommand command) in d:\workspace\git\ncqrs\Framework\src\Ncqrs\Commanding\ServiceModel\CommandService.cs:line 56
at radiochart_driver.Program.Main() in D:\workspace\hg\radiochart\radiochart-driver\Program.cs:line 21
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

@marcofranssen
Copy link

I think I fixed it. However my application still works, so hope it's the correct solution. Already did a pull request.

@aproteau
Copy link

I'm having the same issue.

@marcofranssen
Copy link

I don't know if you can see my pull request with the solution. You can fix it on your own repo until it is merged on the development branche.

@aproteau
Copy link

Thanks! I was able to fix the problem.

I've updated this method to include initialVersion :

private static void UpdateEventSourceVersion(Guid eventSourceId, long newVersion, long initialVersion , SqlTransaction transaction)
{
using (var command = new SqlCommand(Queries.UpdateEventSourceVersionQuery, transaction.Connection))
{
command.Transaction = transaction;
command.Parameters.AddWithValue("Id", eventSourceId);
command.Parameters.AddWithValue("NewVersion", newVersion);
command.Parameters.AddWithValue("initialVersion", initialVersion);

            command.ExecuteNonQuery();
        }
    }

@pjvds pjvds closed this as completed in a0e3ea7 Aug 2, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants