Subscriptions can be deactivated or can expire if they are not synchronized within a specified period of time. The action that occurs depends on the type of replication and the retention period that is exceeded.
If a subscription is not synchronized within a specified period of time, there is a possibility the subscription may get deleted or it may be automatically marked deactivated and require reinitialization. Whether it expires and is deleted or gets marked deactivated and requires initialization depends upon whether it exceeds the subscription expiration property of the publication or the maximum transaction retention property of the distribution database as well as whether or not it is an anonymous subscription.
When a subscription is not synchronized (for example, the Distribution Agent for it has not run or cannot connect to the Subscriber) within the maximum transaction retention period of the distribution database and there are changes in the distribution database waiting to be picked up, the subscription will be marked deactivated by the Distribution Cleanup Agent that runs on the Distributor. The default for maximum transaction retention period is 72 hours for transactional replication and the Distribution Cleanup Agent runs every 10 minutes by default.
If there is no activity at the Publisher, subscriptions will not be deactivated even if they have not been synchronized within the distribution retention period. After a subscription is marked inactive, the Distribution Agent will fail with an error message that informs the user that the subscription has been deactivated and that it needs to be reinitialized. The subscription will then need to be reinitialized and a new snapshot applied at the Subscriber before replication continues for that subscription.
In addition to deactivating subscriptions that have not synchronized within the maximum transaction retention period of the distribution database, the Distribution Cleanup Agent is also responsible for cleaning up transactions in the distribution database that have been delivered to Subscribers with named subscriptions.
If anonymous subscriptions are used, this agent will clean up only transactions in the distribution database that have exceeded the maximum transaction retention period. The Distribution Cleanup Agent will not clean up transactions in the distribution database before the end of the retention period when anonymous subscriptions are used because it cannot be sure that the Subscribers using anonymous subscriptions have received the transactions stored in the distribution database. If you set the retention period to a high value, the distribution database will grow larger if you are using anonymous subscriptions because of this.
To modify a Distributor or add or modify a distribution database
When a subscription does not synchronize (the Distribution Agent for it is not run or cannot connect to the Subscriber) within the subscription expiration period of the publication, the subscription will expire and be dropped by the Expired Subscription Cleanup Agent that runs on the Publisher.
For push subscriptions, the Expired Subscription Cleanup Agent (which runs at the Publisher) will remove the subscriptions at the Publisher and it will remove the Distribution Agent associated with the expired subscriptions. This event is logged as a history message for the Expired Subscription Cleanup Agent. The subscription will need to be re-created for the Subscriber to continue to receive changes from the Publisher.
For pull subscriptions, the Distribution Agent and subscriptions at the Subscriber cannot be removed. The next time the Distribution Agent is run, it will fail, and an error will be returned indicating the subscription associated with the agent has expired and been deleted. There are, however, different messages and actions that need to be taken to continue to receive data at the Subscriber. If you are using named subscriptions, a message will be displayed at the Subscriber stating that the subscription associated with the agent has been removed and needs to be recreated.
The named subscriptions will need to be deleted at the Subscriber as well and re-created. If you are using anonymous subscriptions, a message will be displayed at the Subscriber that the subscription associated with the agent has been removed, and the subscription needs to be reinitialized at the Subscriber after the subsequent agent failure so that a new snapshot is applied at the Subscriber.
The publication retention period for subscriptions is specified on the General tab of the Publication Properties. The default for a transactional publication is 336 hours.
Setting publication retention to "0" means that subscriptions will never expire and be removed.
Important The Distribution Clean Up Agent may still deactivate the subscription if the subscription has not been synchronized within the maximum distribution retention period.
If you do not want subscriptions to expire, set the publication retention to "0", or disable the Expired Subscription Cleanup Agent. If you do not want subscriptions to be deactivated, set the maximum distribution retention period to a higher value than the default of 72 hours taking into consideration the effect it may have on the size of the distribution database.
The publication retention period for subscriptions to merge publications is set to 14 days by default. If the time period between synchronizations is a longer period, you can specify:
If you set the retention period to a high value, Microsoft® SQL Server™ 2000 will not be able to clean up meta data in the publication and subscription databases until the retention period is reached.
Setting the retention period to a lower value for merge replication can help reduce the growth of the merge tracking tables. It is recommended that you use a lower setting if you can reliably predict that all Subscribers will synchronize regularly more frequently than that time period.
The retention period for any republisher must be set to a value equal to or less than the retention period set at the original Publisher. It is recommended that the retention period at the republisher be set to the same value for all Publishers that have the same data for convenience and consistency when managing these settings.
If a subscription is deactivated, the subscription will be removed by the Expired Subscription Clean Up Agent, which runs once a day by default. A subscription is marked as expired either during the cleanup process or when the Merge Agent runs after the retention period has been exceeded.
The Expired Subscription Clean Up Agent will look for all named and anonymous subscriptions for which the Merge Agent has not run within the publication retention period, remove those subscriptions, and log a history message indicating the subscriptions expired and were removed.
For push subscriptions, the Expired Subscription Cleanup Agent (which runs at the Publisher and Distributor) will remove the subscriptions at the Publisher and the Distribution Agent associated with the expired subscriptions. For pull subscriptions, the Merge Agent and subscriptions at the Subscriber cannot be removed. The Merge Agent will fail, and an error will be returned indicating the subscription associated with the agent has expired. You can reinitialize anonymous subscriptions at the Subscriber after the agent failure so that a new snapshot is applied at the Subscriber. However, named subscriptions will need to be dropped and re-created.
Even if the Expired Subscription Cleanup Agent has not run and subscriptions have not been cleaned up, the Merge Agent will still fail if the last synchronization was before the publication retention period.
Setting publication retention to "0" means that subscriptions will never expire and be removed; however, the Distribution Clean Up Agent may still deactivate the subscription if it has not been synchronized during the maximum distribution retention period. The publication retention period for subscriptions is specified on the General tab of the publication properties.