Applies ToSQL Server 2019 on Windows SQL Server 2022 on Linux (all editions) SQL Server 2022 on Windows (all editions)

Symptoms

The sp_replmonitorsubscriptionpendingcmds stored procedure is not compatible with peer-to-peer (P2P) replication. It returns an incorrect number of pending commands. After you apply this fix, sp_replmonitorsubscriptionpendingcmds will be compatible with P2P replication.

Note The "Undistributed Commands" tab of a Replication Monitor invokes sp_replmonitorsubscriptionpendingcmds behind the scenes.

Resolution

Cumulative update information

This problem is fixed in the following cumulative updates for SQL Server:

Note After you apply this cumulative update, sp_replmonitorsubscriptionpendingcmds might still report an incorrect number of pending commands for P2P replication if the MSrepl_originators table contains stale entries.

If the MSrepl_originators table contains stale entries, running sp_replmonitorsubscriptionpendingcmds will generate the following warning message in the SQL Server error log:

Warning: Unable to get database version for the subscription database '<database_name>'. The sp_replmonitorsubscriptionpendingcmdsmay report the incorrect number of pending commands for P2P replication.

To resolve this problem, either delete the stale entries from MSrepl_originators or pass the correct "dbversion" of a subscription database as a subdb_version argument when you run sp_replmonitorsubscriptionpendingcmds.

Tips: You can select either of the following methods to find the "dbversion" of a subscription database:

  • Run the following query on a distribution database:                                                                                        select dbversion from MSrepl_originatorswhere publisher_database_id = <Publisher_Database_ID>and srvname = <Subscriber_Server>and dbname = <Subscriber_Database>Note You need to substitute appropriate values for <Publisher_Database_ID> , <Subscriber_Server> and <Subscriber_Database>.

  • Run the following query on a subscription database:                                                                                    declare @current_version int , @currentGuid uniqueidentifierselect @currentGuid = recovery_fork_guid from sys.database_recovery_statuswhere database_id = db_id()select @current_version = substring(convert(binary(16), isnull(@currentGuid, 0x0)),1,6)print @current_version

Each new cumulative update for SQL Server contains all the hotfixes and security fixes that were in the previous build. We recommend that you install the latest build for your version of SQL Server:

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

References

Learn about the terminology that Microsoft uses to describe software updates.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.