XD7.18 - Schema Upgrade fails with a timeout exception returned by the SQL client

XD7.18 - Schema Upgrade fails with a timeout exception returned by the SQL client

book

Article ID: CTX238539

calendar_today

Updated On:

Description

When running an automatic or manual upgrade from versions 7.16 or below to versions 7.17 or above, the following error occurs: 
 

Inner Exception: 
System.Data.SqlClient.SqlException Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 
at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException) 
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType) 

HelpLink.ProdName : Microsoft SQL Server 
HelpLink.EvtSrc : MSSQLServer 
HelpLink.EvtID : -2 
HelpLink.BaseHelpUrl : http://go.microsoft.com/fwlink 
HelpLink.LinkId : 20476 

Inner Exception: 
System.ComponentModel.Win32Exception The wait operation timed out

When running the upgrade script against the monitoring database, the upgrade process is stuck on Step 10 when upgrade the schema to version 7.17:
 

…
Start schema update to version 7.16.0.0...
  Applying update step #5...
  Applying update step #10...
  Applying update step #15...
  Applying update step #20...
Update to schema version 7.16.0.0 complete.
Start schema update to version 7.17.0.0...
  Applying update step #5...
  Applying update step #10...
 

Activity monitor shows that the following transactions take a long time to complete,eventually leading to the timeout: 

- Transaction 1:

-- ****************** MonitorData.ApplicationInstanceSummary ******************

-- MonitorData.ApplicationInstanceSummary : Create new index
begin transaction;
declare @Step int = 15;
if MonitorData.DoUpdateStep(@Step) = 1 begin
execute MonitorData.StartUpdateStep @Step;
create index IX_AppInstanceSummary_G_SD
    on MonitorData.ApplicationInstanceSummary(Granularity, SummaryDate)
        include(PeakConcurrentInstanceCount, TotalUsageDuration, TotalLaunchesCount, StartingInstanceCount, DesktopGroupId);
end
commit transaction;
 


- Transaction 2: 

UPDATE MonitorData.SessionActivitySummary 
SET ConcurrentSessionCount = ( CASE WHEN ConcurrentSessionCount IS NULL THEN ConnectedSessionCount + DisconnectedSessionCount ELSE ConcurrentSessionCount end);
 




 

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Resolution

Truncate the table content prior to running the upgrade.

truncate table MonitorData.ApplicationInstanceSummary
truncate table MonitorData.SessionActivitySummary

Problem Cause

Tables MonitorData.ApplicationInstanceSummary and MonitorData.SessionActivitySummary are oversized, which greatly increases the time it takes to alter the table definitions.
The tables can be oversized because the grooming has been failing.