KB4557397 - Cumulative Update 21 for SQL Server 2017

Applies to: SQL Server 2017 on Windows (all editions)SQL Server 2017 on Linux (all editions)

This article describes Cumulative Update package 21 (CU21) for Microsoft SQL Server 2017. This update contains fixes that were released after the initial release of SQL Server 2017 and updates the SQL Server and Analysis services components to the following builds:

Component Product version File version
SQL Server 14.0.3335.7 2017.140.3335.7
Analysis Services 2017.140.249.51


Important notices

This article also provides important information about the following situations:

  • Pacemaker: A behavioral change is made in distributions that use the latest available version of Pacemaker. Mitigations methods are provided.
  • Query Store: You must run this script if you use Query Store and you have previously installed SQL Server 2017 Cumulative Update 2 (CU2).
  • Analysis Services CU build version: Beginning in SQL Server 2017, the Analysis Services build version number and SQL Server Database Engine build version number do not match. For more information, see Verify Analysis Services cumulative update build version.

Cumulative updates

Cumulative updates (CU) are now available at the Microsoft Download Center.

Only the most recent CU that was released for SQL Server 2017 is available at the Download Center.

CU packages for Linux are available at https://packages.microsoft.com/.


  • Each new CU contains all the fixes that were included with the previous CU for the installed version of SQL Server.
  • SQL Server CUs are certified to the same levels as Service Packs, and should be installed at the same level of confidence.
  • Microsoft recommends ongoing, proactive installation of CUs as they become available according to these guidelines:
    • Historical data shows that a significant number of support cases involve an issue that has already been addressed in a released CU.
    • CUs may contain added value over and above hotfixes. This includes supportability, manageability, and reliability updates.
  • We recommend that you test CUs before you deploy them to production environments.

How to obtain this cumulative update package for Windows

The following update is available from the Microsoft Download Center:

If the download page does not appear, contact Microsoft Customer Service and Support to obtain the cumulative update package.


  • After future cumulative updates are released for SQL Server 2017, this and all previous CUs can be downloaded from the Microsoft Update Catalog. However, we recommend that you always install the latest cumulative update that is available.

How to obtain this cumulative update package for Linux

To update Linux to the latest CU, you must first have the Cumulative Update repository configured. Then, update your SQL Server packages by using the appropriate platform-specific update command.

For installation instructions and direct links to the CU package downloads, see the release notes.

Additional hotfixes that are included in this cumulative update package

VSTS bug number KB article number Description Fix area Platform
13554273   This update contains an improvement for object level lock optimization on secondary replicas of Always On Availability Groups and addresses the schema lock contention on secondary replica redo, when the number of logical processors is large High Availability All
13561699   Fixes an issue where sys.dm_db_stats_histogram does not show NULL value histogram step in SQL Server 2017 SQL performance All
13546338 3195888 FIX: High CPU usage causes performance issues in SQL Server 2016 and 2017 SQL Engine All
13323992 4521599 FIX: Non-yielding scheduler condition occurs if large number of row-column values are processed in row groups in SQL Server 2016 and 2017 SQL Engine All
13502382   Fixes self-deadlock with database log flush queue spinlock SQL Engine  Linux
13477385   Fixes an assertion exception (Location:sosmemobj.cpp:LineNumber, Expression: pvb->FInUse ()) while querying the DMV sys.dm_hadr_automatic_seeding High Availability Windows
13530833   Access violation exception occurs when a query that references a non-existing partition function is executed in SQL Server 2017 SQL performance Windows
13543457   When using FileTables in SQL Server, you may notice dumps being generated periodically that contain an assertion in function FFtFileObject::ProcessPostCreate. In some environments, these dumps may trigger a failover                                            FtFileObject::ProcessPostCreate file = fftfo.cpp line = LineNumber  expression = FALSE SQL Engine Windows
13488604   The DELETE from CONSTITUENT table in SQL Server 2017 fails with error even when the table has no matching rows in the referenced tables                        Msg 547, Level 16, State 0, Line LineNumber
The DELETE statement conflicted with the REFERENCE constraint "ConstraintName". 
The conflict occurred in database "DatabaseName", table "TableName", column 'ColumnName'.
The statement has been terminated
SQL performance Windows
13490178   Fixes long duration taken for Integration Services Project deployment through powershell by improving search of operation messages in deployment process Integration services Windows
13495359   Error occurs when you create a session cube on a database and then try to query from that session cube in SQL Server 2017                                          "Server: The operation has been cancelled because there is not enough memory available for the application. If using a 32-bit version of the product, consider upgrading to the 64-bit version or increasing the amount of memory available on the machine." Analysis Services Windows
13502024   sys.key_constraints reports two rows (duplicate) for an index if we have an XML component id with an id which is the same as the "object_id" of a primary key SQL Engine Windows
13503404   R Setup components fails to download CAB files when TLS 1.0 is disabled. This update includes a new R Setup version to add support for TLS1.2 Setup & Install Windows
13563530   Executing sys.fn_xe_file_target_read_file may cause SQL Server to crash SQL Engine Windows
13564527   Column Description disappears after exporting/importing models through MDSModelDeploy for an approval required entity in SQL Server 2017 Data Quality Services (DQS) Windows
13574528   Improves SSISDB performance by adding indexes to event_message_context and execution_property_override_values tables in SQL Server 2017 Integration services Windows
13455278   When you use mashup to import from Active Directory by using the default M query generated from the connection wizard, you may encounter "Key Expression Error: The key didn't match any rows in the table" Analysis Services Windows
13458572   Spatial data types (Geometry and Geography) are implemented as CLR data types in SQL Server. When the application domain hosting the spatial data type structures is unloaded, the engine treats this as a schema change to the underlying objects referenced in the cursor. As a result, spatial query may fail with related error message when the schema change is detected SQL Engine Windows
13468501   Assume that you run a MDX query with YTD and select multiple members on column, you notice that incorrect result may return in SSAS Tabular instance. However, correct result will return if you run the similar MDX query with YTD but select each individual members on column Analysis Services Windows
13473122   When you try to refresh a model that contains many measures with USERELATIONSHIP function, SSAS can take many minutes before sending out queries to read from the data source. This fix can improve the processing performance and data source queries will be sent out very soon after the initial "sequence point algorithm" step Analysis Services Windows
13515392   Fixes an access violation while frequently restarting Extended Event session with QueryPlanProfile event in SQL Server 2017 SQL performance Windows
13516058   This improvement can force the Query Store option to be turned off by specifying the additional option FORCED in the ALTER DB command. FORCED option allows you to turn off Query Store immediately by aborting all background tasks.  ALTER DATABASE {0} SET QUERY_STORE = OFF (FORCED) SQL Engine Windows
13525859   Fixes an access violation with recursive CTE whose anchor member is a clustered Columnstore index SQL performance Windows
13530057   This improves MDX query execution performance against a dimension user hierarchy which is ragged hierarchy (HidememberIf property set) and has deep hierarchy level in SSAS Multidimensional instance Analysis Services Windows
13421890 4540896 FIX: Access violation may occur when enumerating files in a FileTable in SQL Server SQL Engine Windows
13422969 4564868 FIX: Assertion exception occurs when you query the DMV sys.dm_db_file_space_usage in SQL Server 2017 and 2019 SQL Engine Windows
13508566 4562173 FIX: Availability Group failover generates lot of dumps as DTC support is toggled between PER_DB and NONE multiple times High Availability Windows
13578386 4565944 Improvement: A manual method to set maximum group commit time in SQL Server 2017 High Availability Windows
13387895 4567166 FIX: Assertion failure occurs when you try to insert record into a page in fully logged mode in SQL Server 2017 SQL Engine Windows
13545675 4567837 FIX: Script downgrade may fail when Cumulative Update 20 (CU20) is uninstalled from SQL server 2017 SQL Engine Windows
13042339 4569425 FIX: Transactional replication publications can support URL type device to initialize subscriptions from backups in Azure Blob Storage in SQL Server 2017 SQL Engine Windows
13603817 4563597 FIX: Assertion dump may occur when Implicit Transactions are enabled in SQL Server 2016 and 2017 SQL Engine Windows

Notes for this update

Known issues

Under certain circumstances, there is a known uninstallation issue that affects SQL Server 2017 CU 20. After you uninstall CU 20, SQL Server doesn’t come online, and the following error entry is logged in the SQL Server log:

Mitigation is to enable Trace Flag - T902, then SQL server will come online and you are done. You don’t have to uninstall it again. To upgrade to the new CU, you have to first remove this flag.

SQL Server 2017 CU21 or any later CU release contains the fix.

Hybrid environments deployment

When you deploy an update to a hybrid environment (such as AlwaysOn, replication, cluster, and mirroring), we recommend that you refer to the following articles before you deploy the update:

More CU package information


To apply this cumulative update package, you must be running SQL Server 2017.

Restart information

You may have to restart the computer after you apply this cumulative update package.

Registry information

To use one of the hotfixes in this package, you do not have to make any changes to the registry.

Pacemaker notice


All distributions (including RHEL 7.3 and 7.4) that use the latest available Pacemaker package 1.1.18-11.el7 introduce a behavior change for the start-failure-is-fatal cluster setting when its value is false. This change affects the failover workflow. If a primary replica experiences an outage, the cluster is expected to failover to one of the available secondary replicas. Instead, users will notice that the cluster keeps trying to start the failed primary replica. If that primary never comes online (because of a permanent outage), the cluster never fails over to another available secondary replica.

This issue affects all SQL Server versions, regardless of the cumulative update version that they are on.

To mitigate the issue, use either of the following methods.

Method 1

Follow these steps:

  1. Remove the start-failure-is-fatal override from the existing cluster. 
       # RHEL, Ubuntu         pcs property unset start-failure-is-fatal         # or         pcs property set start-failure-is-fatal=true   # SLES         crm configure property start-failure-is-fatal=true
  2. Decrease the cluster-recheck-interval value. 
       # RHEL, Ubuntu         pcs property set cluster-recheck-interval=<Xmin>   # SLES         crm configure property cluster-recheck-interval=<Xmin>
  3. Add the failure-timeout meta property to each AG resource. 
       # RHEL, Ubuntu         pcs resource update ag1 meta failure-timeout=60s   # SLES         crm configure edit ag1      # In the text editor, add `meta failure-timeout=60s` after any `param`s and before any `op`s

    Note In this code, substitute the value for <Xmin> as appropriate. If a replica goes down, the cluster tries to restart the replica at an interval that is bound by the failure-timeout value and the cluster-recheck-interval value. For example, if failure-timeout is set to 60 seconds and cluster-recheck-interval is set to 120 seconds, the restart is tried at an interval that is greater than 60 seconds but less than 120 seconds. We recommend that you set failure-timeout to 60s and cluster-recheck-interval to a value that is greater than 60 seconds. Setting cluster-recheck-interval to a small value is not recommended. For more information, refer to the Pacemaker documentation or consult the system provider.

Method 2

Revert to Pacemaker version 1.1.16.

    Query Store notice


    You must run this script if you use Query Store and you are updating from SQL Server 2017 Cumulative Update 2 (CU2) directly to SQL Server 2017 Cumulative Update 3 (CU3) or any later Cumulative Update. Executing this script is not needed if you have previously installed SQL Server 2017 Cumulative Update 3 (CU3) or any later SQL Server 2017 Cumulative Update.

    SET NOCOUNT ON;DROP TABLE IF EXISTS #tmpUserDBs;SELECT [database_id], 0 AS [IsDone]INTO #tmpUserDBsFROM master.sys.databasesWHERE [database_id] > 4 AND [state] = 0 -- must be ONLINE AND is_read_only = 0 -- cannot be READ_ONLY AND [database_id] NOT IN (SELECT dr.database_id FROM sys.dm_hadr_database_replica_states dr -- Except all local Always On secondary replicas  INNER JOIN sys.dm_hadr_availability_replica_states rs ON dr.group_id = rs.group_id  INNER JOIN sys.databases d ON dr.database_id = d.database_id  WHERE rs.role = 2 -- Is Secondary   AND dr.is_local = 1   AND rs.is_local = 1)DECLARE @userDB sysname;WHILE (SELECT COUNT([database_id]) FROM #tmpUserDBs WHERE [IsDone] = 0) > 0BEGIN SELECT TOP 1 @userDB = DB_NAME([database_id]) FROM #tmpUserDBs WHERE [IsDone] = 0 -- PRINT 'Working on database ' + @userDB EXEC ('USE [' + @userDB + '];DECLARE @clearPlan bigint, @clearQry bigint;IF EXISTS (SELECT [actual_state] FROM sys.database_query_store_options WHERE [actual_state] IN (1,2))BEGIN IF EXISTS (SELECT plan_id FROM sys.query_store_plan WHERE engine_version = ''14.0.3008.27'') BEGIN  DROP TABLE IF EXISTS #tmpclearPlans;  SELECT plan_id, query_id, 0 AS [IsDone]  INTO #tmpclearPlans  FROM sys.query_store_plan WHERE engine_version = ''14.0.3008.27''  WHILE (SELECT COUNT(plan_id) FROM #tmpclearPlans WHERE [IsDone] = 0) > 0  BEGIN   SELECT TOP 1 @clearPlan = plan_id, @clearQry = query_id FROM #tmpclearPlans WHERE [IsDone] = 0   EXECUTE sys.sp_query_store_unforce_plan @clearQry, @clearPlan;   EXECUTE sys.sp_query_store_remove_plan @clearPlan;   UPDATE #tmpclearPlans   SET [IsDone] = 1   WHERE plan_id = @clearPlan AND query_id = @clearQry  END;  PRINT ''- Cleared possibly affected plans in database [' + @userDB + ']'' END ELSE BEGIN  PRINT ''- No affected plans in database [' + @userDB + ']'' ENDENDELSEBEGIN PRINT ''- Query Store not enabled in database [' + @userDB + ']''END')  UPDATE #tmpUserDBs  SET [IsDone] = 1  WHERE [database_id] = DB_ID(@userDB)END

    Filestream notice

    There is a known issue that affects the Filestream and FileTable features on Windows Server 2012 and Windows 8 operating systems. Do not apply this CU if you use one of these SQL Server features and you are running on one of these identified operating systems.

    If you have already applied this CU, you may see the following message in the SQL Server error log:

    You may also see the following entry in the Windows System event log:

    Additionally, you may also experience failures when you try to install the CU or enable the Filestream feature after the CU is installed.

    To work around the issue, uninstall SQL Server 2017 CU21. This issue is scheduled to be fixed in a future CU.