Build 1920 - Deadlock

Sorry, something bad happened yesterday in my event log. I'll let you review the reasons behind it.

Build Trigger

Error trigering build. Message: Exception: AggregateException
Message: One or more errors occurred.
Stack Trace:

Exception: GenericADOException
Message: could not execute query
[ select build0_.Id as Id32_, build0_.BuildNumber as BuildNum2_32_, build0_.Version as Version32_, build0_.Started as Started32_, build0_.Finished as Finished32_, build0_.Queued as Queued32_, build0_.Pinned as Pinned32_, build0_.PinComment as PinComment32_, build0_.Priority as Priority32_, build0_.SummaryState as Summary10_32_, build0_.BuildSuccess as BuildSu11_32_, build0_.OnlyNotifyTriggeringUsers as OnlyNot12_32_, build0_.QuietPeriodLength as QuietPe13_32_, build0_.QuietPeriodExpiry as QuietPe14_32_, build0_.TimeOnQueue as TimeOnQ15_32_, build0_.IsFeatureBranchBuild as IsFeatu16_32_, build0_.UsesDefaultBranch as UsesDef17_32_, build0_.CleanedUp as CleanedUp32_, build0_.HasNewChanges as HasNewC19_32_, build0_.Branches as Branches32_, build0_.State as State32_, build0_.status_message as status22_32_, build0_.status_datetime as status23_32_, build0_.ConfigurationVersionId as Configu24_32_, build0_.ConfigurationId as Configu25_32_, build0_.WorkspaceId as Workspa26_32_, build0_.UserId as UserId32_, build0_.PinUserId as PinUserId32_, build0_.TriggerId as TriggerId32_, build0_.VariableNamespaceId as Variabl30_32_ from builds_build build0_ where build0_.ConfigurationId=@p0 and build0_.TriggerId=@p1 and (build0_.SummaryState=@p2 or build0_.SummaryState=@p3) and build0_.QuietPeriodLength>@p4 ]
Name:p1 - Value:d946f8da-3ca6-444f-8646-a19400d62206 Name:p2 - Value:9106647b-ea21-49b6-9a33-a1a200b251dc Name:p3 - Value:4 Name:p4 - Value:0 Name:p5 - Value:0
[SQL: select build0_.Id as Id32_, build0_.BuildNumber as BuildNum2_32_, build0_.Version as Version32_, build0_.Started as Started32_, build0_.Finished as Finished32_, build0_.Queued as Queued32_, build0_.Pinned as Pinned32_, build0_.PinComment as PinComment32_, build0_.Priority as Priority32_, build0_.SummaryState as Summary10_32_, build0_.BuildSuccess as BuildSu11_32_, build0_.OnlyNotifyTriggeringUsers as OnlyNot12_32_, build0_.QuietPeriodLength as QuietPe13_32_, build0_.QuietPeriodExpiry as QuietPe14_32_, build0_.TimeOnQueue as TimeOnQ15_32_, build0_.IsFeatureBranchBuild as IsFeatu16_32_, build0_.UsesDefaultBranch as UsesDef17_32_, build0_.CleanedUp as CleanedUp32_, build0_.HasNewChanges as HasNewC19_32_, build0_.Branches as Branches32_, build0_.State as State32_, build0_.status_message as status22_32_, build0_.status_datetime as status23_32_, build0_.ConfigurationVersionId as Configu24_32_, build0_.ConfigurationId as Configu25_32_, build0_.WorkspaceId as Workspa26_32_, build0_.UserId as UserId32_, build0_.PinUserId as PinUserId32_, build0_.TriggerId as TriggerId32_, build0_.VariableNamespaceId as Variabl30_32_ from builds_build build0_ where build0_.ConfigurationId=@p0 and build0_.TriggerId=@p1 and (build0_.SummaryState=@p2 or build0_.SummaryState=@p3) and build0_.QuietPeriodLength>@p4]
Stack Trace: at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results)
at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters)
at NHibernate.Impl.ExpressionQueryImpl.List()
at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
at Remotion.Linq.QueryableBase`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Continua.Modules.Builds.BuildManager.GetQuietPeriodBuildsForTriggerConfiguration(Trigger trigger)
at Continua.Modules.Builds.Triggers.TriggerController.DoQueueBuild(Guid triggerId, IEnumerable`1 buildChangesets, IApplicationSessionContext session, Boolean onlyNotifyTriggeringUsers)
at Continua.Modules.Builds.Triggers.TriggerController.QueueBuildChangesetBuild(Guid triggerId, ChangesetDTO change, ICoreApplicationContext context, Boolean onlyNotifyTriggeringUsers)
at Continua.Modules.Builds.Triggers.TriggerMessageContext.<>c__DisplayClass1.
b__0()
at System.Threading.Tasks.Task.Execute()

Exception: SqlException
Message: Transaction (Process ID 60) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
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.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
at System.Data.SqlClient.SqlDataReader.Read()
at NHibernate.Driver.NHybridDataReader.Read()
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)

Hmm… sql server how I do love thee… not. We’ve seen deadlock issues before in other areas and have code in place to try and deal with them, but this is the first time I have seen a deadlock in this area. FWIW, we have never seen a deadlock with postgresql. We’ll look into it.