ADO Exception: Foreign Key contraint

G'day,

I think this relates to the installation of v1.0.0.1437, which I did at the time the error occurred. I didn't notice this till today.  I suspect I was setting up a new project at the time. I'm going to assume I was setting up a SVN link to https://nbstore.svn.codeplex.com/svn and I tried to validate, failed and then ignored the validation failure and saved the existing settings.

Importance: Error

Date: Saturday, 9 February 2013
Time: 8:21:18 AM

Message:

Exception: GenericADOException
Message: could not execute batch command.[SQL: SQL not available]
Stack Trace:    at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)
   at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)
   at NHibernate.AdoNet.SqlClientBatchingBatcher.AddToBatch(IExpectation expectation)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session)
   at NHibernate.Action.EntityInsertAction.Execute()
   at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
   at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
   at NHibernate.Engine.ActionQueue.ExecuteActions()
   at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
   at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
   at NHibernate.Impl.SessionImpl.Flush()
   at NHibernate.Transaction.AdoTransaction.Commit()
   at Continua.Shared.Data.Hibernate.NHibernateDatabase.SaveChanges()
   at Continua.Modules.Builds.Agents.AgentManager.Register(String address, String hostname, Int32 port, String version)
   at Continua.Modules.Builds.Services.AgentRegistrationService.Register(String hostname, Int32 port, String version)
   at SyncInvokeRegister(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Exception: SqlException
Message: The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The INSERT statement conflicted with the FOREIGN KEY constraint "fk_builds_agentproperty_to_builds_agent". The conflict occurred in database "JD_Continua", table "dbo.builds_agent", column 'id'.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
The statement has been terminated.
Stack Trace:    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.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)
   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.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Data.SqlClient.SqlCommandSet.ExecuteNonQuery()
   at NHibernate.AdoNet.SqlClientBatchingBatcher.DoExecuteBatch(IDbCommand ps)

Hey Jamie, that’s a weird error that we are having trouble reproducing. It shouldn’t have anything to do with validating your SVN repository. The error looks like its trying to add property collectors to the agent but the agent doesn’t exist…

To test whether this is a once off issue, head to the agents page in the admin section and delete the agent. If the agent is the one that also runs on the build server then it will automatically be added again shortly after. If you could let us know if you get this error again when the agent is re-added then we can get to the bottom of this issue.

Cheers,
Dave

Dave,

Ok I deleted both agents and they eventually re-appeared in the unauthorized section. Interestingly it complained about security problems in the warning rollover (wrong?).

Attachment unavailable

Ok it all looks good now Jamie. Seems to have been a weird error that we cannot reproduce.

If you can delete and re-add agents, like you have done, suggests that you will not see it again

I’m happy it was a one off issue.