Timeout expired when querying SQL Server via NHibernate - sql-server

I have an ASP.Net MVC application that uses SQL Server 2005 via NHibernate. I am getting getting the following error message sporadically:
"System.Data.SqlClient.SqlException (0x80131904): Timeout expired.
The timeout period elapsed prior to completion of the operation or the
server is not responding. 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.SqlDataReader.SetMetaData(_SqlMetaDataSet
metaData, Boolean moreInfo) at
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData() 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.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) at
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) at
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean
autoDiscoverTypes, Boolean callable, RowSelection selection,
ISessionImplementor session) 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)"
Most of the time the system works fine and is very responsive. I have looked into the locks being held on the system and what I typically find is there is one query being blocked by another query:
"SELECT TOP 10 d.Id, d.Name FROM Documents d INNER JOIN Users u ON..."
is being blocked by:
"SELECT TOP 10 Id, Name FROM Users"
Looking at the locks being held by the blocking statement there are around a dozen exclusive (X) and (IX) page and key locks on various tables unrelated to the Users table (but that are part of the query that is being blocked).
There are no UPDATES, INSERTS or DELETES involved here - so why would one read-only query block the other and why would a simple query on the Users table cause locks on lots of other tables.

A SQL Server gotcha is a non-default "isolation-level" setting on the database. SQL Server has a default isolation-level (locking strategy) of ReadCommitted which means that read locks are released as soon as possible but write locks are not released until a transaction is committed. In Andy's answer, the default isolation-level will cause the select to be blocked. However if the database is set to either RepeatableRead or Serializable, then selects will always block each other for the duration of a transaction. This setting can be controlled in NHibernate with this hibernate.cfg.xml config:
<session-factory>
...
<add key="hibernate.connection.isolation" value="ReadCommitted" />
...
</session-factory>

This would cause the issue:
begin transaction
update Documents
set SomeField = 'SomeValue'
where SomeCondition = 'XXXX'
select top 10 Id, Name from Users
commit
The locks created on the document table during the update won't be released until you commit the transaction. This would mean that a connection could have the select statement as its most recent statement, but still be holding locks from the previous update.
Some ideas:
Make sure you are committing/rolling back your transactions
Try to reduce the length of your transactions (e.g. in the above, would it be safe to commit before running the select?).
Optimizing the join on the update by making sure the foreign key is indexed might also speed up the transaction.
Note that a select itself will only generate shared locks.
Finally beware of the (nolock) lock hint idea. Reading uncommitted data is rarely a good idea.

Related

Invalid Column Name when copying database between instances

I am using the Copy Database feature in SSMS. The source instance is v 2012, the target instance is v 2019.
I am able to copy other databases in the source instance to the target instance. This particular database fails.
This message is from the Windows Event Viewer on the target machine. "InnerException-->Invalid column name 'Description'." does not make sense because there is
a column with that name in one of the tables in the source database. I can't tell what table it's complaining about from the message in the Windows Event Log.
There is one table in the source database with a column called Description:
Event Name: OnError
Message: An error occurred while transferring data. See the inner exception for details.
StackTrace: at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferDatabasesUsingSMOTransfer()
InnerException-->Invalid column name 'Description'.
StackTrace: 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.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.Smo.Transfer.ExecuteStatements(SqlConnection destinationConnection, IEnumerable`1 statements, SqlTransaction transaction)
at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
Operator: NT Service\SQLAgent$MSSQLSERVER2019
Source Name: CDW_IL-SERVER-001_MSSQLSERVER2012_IL-SERVER-002_MSSQLSERVER2019_8
Source ID: {6FCAF562-8C02-4A7F-BDE0-9B985BE99BCB}
Execution ID: {C9D1672E-366F-49C2-B98F-903B080DF36A}
Start Time: 8/14/2020 9:11:21 AM
End Time: 8/14/2020 9:11:21 AM
Data Code: 0

SQL Server Error: A timeout occurred while waiting for memory resources to execute the query in resource pool 'internal' (1). Rerun the query

Some of my queries having Left joins and Unions were working perfectly till the data in my base tables crossed couple of thousand records.
Now the same queries in the stored procedures are raising timeout errors.
I am not sure whether to tweak the SQL queries from my side or do any memory settings on SQL server.
Error Text:
A timeout occurred while waiting for memory resources to execute the
query in resource pool 'internal' (1). Rerun the query.
8/28/2018 7:15:50 AM Error: A timeout occurred while waiting for
memory resources to execute the query in resource pool 'internal' (1).
Rerun the query. at
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection, Action1 wrapCloseInAction) at
System.Data.SqlClient.SqlInternalConnection.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
XXXXXX.Dal.Configuration.ConfigurationDAL.GetUsers(String
tenantConnectionString, Int32 entityId, Boolean includeUserGroups,
Int32 getUsersMode)

What is the permission needed for a SQL Server login to change a tables name?

I am building out my database using EF Core 2.1 code first migrations. I have altered a table to rename. The migration initially dropped the entire table and then read it with the new name, which had issues with foreign key constraints. I changed the migration to use the RenameTable method instead like
migrationBuilder.RenameTable("TourSpecs", "TourSpecHistory");
When running update-database I get the error
Failed executing DbCommand (27ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
DECLARE #defaultSchema sysname = SCHEMA_NAME();
EXEC(N'ALTER SCHEMA ' + #defaultSchema + N' TRANSFER [TourSpecHistory].[TourSpecs];');
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (27ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
DECLARE #defaultSchema sysname = SCHEMA_NAME();
EXEC(N'ALTER SCHEMA ' + #defaultSchema + N' TRANSFER [TourSpecHistory].[TourSpecs];');
System.Data.SqlClient.SqlException (0x80131904): Cannot find the object 'TourSpecs', because it does not exist or you do not have permission.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 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.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
ClientConnectionId:332393e8-8539-4c80-b24c-6478ec61b55b
Error Number:15151,State:1,Class:16
System.Data.SqlClient.SqlException (0x80131904): Cannot find the object 'TourSpecs', because it does not exist or you do not have permission.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 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.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
ClientConnectionId:332393e8-8539-4c80-b24c-6478ec61b55b
Error Number:15151,State:1,Class:16
Cannot find the object 'TourSpecs', because it does not exist or you do not have permission.
Thinking this is just a permissions issue I ran the command
GRANT ALTER ON SCHEMA:: [dbo].[TourSpec] TO ApplicationLogin
But was hit with the error
Cannot find the schema 'dbo.TourSpec', because it does not exist or you do not have permission.
The login I am using to run the grant script has the ALTER ANY SCHEMA permission. What do I need to do to get the correct permissions granted to my ApplicationLogin user?
After #Sean Lange pointed out that I had an incorrect understanding of what was a schema and what an object, I successfully granted the permissions to my user but was still unable to run the migration. Looking through the RenameTable method further, I discovered that it takes in 3 optional arguments at the end and that the migration was incorrectly try to alter a [TourSpecHistory].[TourSpecs] table.
I changed the migration to run migrationBuilder.RenameTable("TourSpecs", "dbo", "TourSpecHistory", "dbo"); and it now works correctly

What does "[Pre-Login] initialisation=xyz" mean in an SQL Exception?

What does the [Pre-Login] initialisation=A; handshake=B; [Login] initialization=C; authentication=D; [Post-Login] complete=E; portion mean in an SQL Timeout Exception?
For example, in the following SQL Timeout exception message, are they seconds, milliseconds, units or apples?
System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. This failure occurred while attempting to connect to the routing destination. The duration spent while attempting to connect to the original server was - [Pre-Login] initialization=28; handshake=24; [Login] initialization=0; authentication=0; [Post-Login] complete=1;
---> System.ComponentModel.Win32Exception: The wait operation timed out
Context
I'm trying to understand the root cause of an SQL Timeout on SQL Azure
Thanks.
Longer StackTrace
---> NHibernate.Exceptions.GenericADOException: could not execute batch command.[SQL: SQL not available]
---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
This failure occurred while attempting to connect to the routing destination. The duration spent while attempting to connect to the original
server was - [Pre-Login] initialization=28; handshake=24; [Login] initialization=0; authentication=0; [Post-Login] complete=1;
---> System.ComponentModel.Win32Exception: The wait operation timed out
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
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, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
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.SqlCommand.ExecuteNonQuery()
at System.Data.SqlClient.SqlCommandSet.ExecuteNonQuery()
at NHibernate.SqlAzure.ReliableSqlClientBatchingBatcher.ExecuteBatch(IDbCommand ps)
--- End of inner exception stack trace ---
at NHibernate.SqlAzure.ReliableSqlClientBatchingBatcher.ExecuteBatch(IDbCommand ps)
at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0()
at Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatchWithTiming(IDbCommand ps)
at NHibernate.AdoNet.AbstractBatcher.ExecuteBatch()
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 ____.Shared.NHibernate.NHibernateRepoSession.Dispose() in c:\\_____\\NHibernateRepoSession.cs:line 48
at ____.Store(String sourceId, String userId, ImageData imageData) in c:\\_____.cs:line 44
...
I hunted down this issue and got a response from SQL support: A, B, C, D, and E represent the steps of a connection attempt:
[Pre-Login] initialization=A; handshake=B; [Login] initialization=C; authentication=D; [Post-Login] complete=E;
A. The connecting client and the server introduce themselves. The client and server let the other know how it intends to communicate.
B. A Secured Socket Layer connection is established.
C. The connecting client introduces itself to the Master database / database.
D. The Master database / database are referenced to complete authentication.
E. A connection has been successfully established.

TFS - Test Management Warehouse Sync - SQL Timeout

Ever since we upgraded TFS 2013 - TFS 2013 update 2 our "Test Management Warehouse" fails to sync. It throws a SQL timeout after 1 hour.
We run a heck of alot of automation tests, thus our test management warehouse is reasonably large.
Here is a thread to a microsoft issue regarding the same kind of thing but for the "Build Warehouse Sync" - My guess is its kind of the same issue however we dont have many builds but have tonnes of tests.
Things I've done to try and fix:
Run a full Rebuild (Drops warehouse and starts again)
No effect
Rebuilt all the indexes on the tfs_defaultcollection
Queries run faster now but no effect on issue
Increased the timeout "WarehouseCommandSqlTimeout" from 1 hour to 3 hours
Still fails after 1 hour so my guess is there is a global SQL connection timeout of 1 hour somewhere??
As a hotfix for now, id like to increase the SQL connection timeout to 3 hours and see if that makes a difference. Does anyone know where that setting is?
This is the error:
[Test Management Warehouse Sync]: ---> Microsoft.TeamFoundation.Warehouse.WarehouseException: TF221122: An error occurred running job Test Management Warehouse Sync for team project collection or Team Foundation server DefaultCollection. ---> Microsoft.TeamFoundation.Framework.Server.DatabaseOperationTimeoutException: TF246018: The database operation exceeded the timeout limit and has been cancelled. Verify that the parameters of the operation are correct. ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out --- End of inner exception stack trace --- at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 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.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() 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, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.Execute(ExecuteType executeType, CommandBehavior behavior) --- End of inner exception stack trace --- at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.TranslateException(Int32 errorNumber, SqlException sqlException, SqlError sqlError) at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.TranslateException(SqlException sqlException) at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.MapException(SqlException ex, QueryExecutionState queryState) at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.HandleException(Exception exception) at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.Execute(ExecuteType executeType, CommandBehavior behavior) at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.ExecuteReader() at Microsoft.TeamFoundation.TestManagement.Warehouse.WarehouseResultDatabase.QueryTestPointData(SqlBinary watermark, Int32 limit, ProcessRowCallback deletedCallback, ProcessMappingDataCallback addedCallback, ResolveIdentities resolveIdentitiesCallBack) at Microsoft.TeamFoundation.TestManagement.Warehouse.TeamTestWarehouseAdapter.QueryForTestPoints(WarehouseResultDatabase wrd, SqlBinary waterMark, Int32 limit) at Microsoft.TeamFoundation.TestManagement.Warehouse.TeamTestWarehouseAdapter.ProcessIntegratedResults(WarehouseRowVersionQueryDelegate wqd, String highWaterMarkProperty, String processLimitProperty, Int32 defaultLimit) at Microsoft.TeamFoundation.TestManagement.Warehouse.TeamTestWarehouseAdapter.MakeDataChanges() at Microsoft.TeamFoundation.Warehouse.WarehouseSyncJobExtension1.MakeDataChanges(TeamFoundationRequestContext requestContext, TeamFoundationJobDefinition jobDefinition, String& resultMessage) at Microsoft.TeamFoundation.Warehouse.WarehouseSyncJobExtension1.RunInternal(TeamFoundationRequestContext requestContext, TeamFoundationJobDefinition jobDefinition, DateTime queueTime, String& resultMessage) at Microsoft.TeamFoundation.Warehouse.WarehouseJobExtension.Run(TeamFoundationRequestContext requestContext, TeamFoundationJobDefinition jobDefinition, DateTime queueTime, String& resultMessage) --- End of inner exception stack trace ---
You can change the logging of the job agent by altering the TFSJobAgent.exe.config file. it can be found here:-
C:\Program Files\Microsoft Team Foundation Server 12.0\Application Tier\TFSJobAgent
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<!--To enable tracing to file, simply uncomment listeners section and set trace switch(es) below.
Directory specified for TextWriterTraceListener output must exist, and job agent service account must have write permissions. -->
<!--<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\Replace_Me_With_A_Directory_The_Service_Account_Can_Write_To\jobagent.log" />
<remove name="Default" />
</listeners>-->
</trace>
<switches>
<!-- Trace Switches
Each of the trace switches should be set to a value between 0 and 4, inclusive.
0: No trace output
1-4: Increasing levels of trace output; see Systems.Diagnostics.TraceLevel-->
<add name="API" value="0" />
<add name="Authentication" value="0" />
<add name="Authorization" value="0" />
<add name="Database" value="0" />
<add name="General" value="0" />
<add name="traceLevel" value="0" />
</switches>
</system.diagnostics>
This may give you better diagnostics with which to investigate the issue
For timeout settings see http://msdn.microsoft.com/en-us/library/ff458305.aspx

Resources