sql-serverdatabase-replicationtransactional-replicationalwayson

SQL Server transactional replication to Alwayson group


I have 3 servers.

Server A, with a publication database, this server is not part of alwayon group, this server is the distributor

Server RT1 and RT2, those servers as part of alwayson group

Listener RT, the listener have the subscription to Server A, and inside we have RT1 AND RT2

The issue is: RT2 is read only because is secondary replica, so all replication to this subscription will be in queue until the server will be primary(on failover) thats means when RT2 will be primary will take all replication in queue and start to replicate one by one then RT1 will be secondary with read only and the issues of the replication in queue

If there is another way to configure the replication to Alwayson group that always replicate to primary server and in the case of failover switch the connection with no replications in queue for read only server?

Note: Server A is not a part of alwayson group also Server A is the publisher, and RT1 or RT2 cannot be publishers

Thanks in advance


Solution

  • When an AG listener is configured as a replication subscriber, the replication will flow to the primary node and then be synchronized to the secondary node. After a failover, the new primary node only has to process replicated transactions that occurred during the failover.

    Check out these links for more information:

    https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/configure-replication-for-always-on-availability-groups-sql-server

    https://learn.microsoft.com/en-us/sql/database-engine/availability-groups/windows/replication-subscribers-and-always-on-availability-groups-sql-server