My subscriber database lost connection to the publisher and expired. Can my data be saved?

前端 未结 1 732
鱼传尺愫
鱼传尺愫 2021-01-23 13:02

I have a publisher database A and I have two subscriber databases B and C that subscribe to A. My application resides locally at sites B and C and through replication, changes a

相关标签:
1条回答
  • 2021-01-23 13:45

    We have been using merge replication for years and sometimes (after DB updates for example) it does break with weird errors which are impossible to fix no matter what we try. In all those cases the ONLY solution that worked was to reinitialize subscriptions or even remove and re-create publications with all subscriptions.

    But since it is the merge replication case and new data is being added at all ends (i.e. publisher and all subscribers) when syncs are not happening we cannot simply re-init subscriptions because like you have pointed out not synchronized data generated at failed subscriber's side will be lost. Your case is even more difficult because you are using encryption and XML files to store data. Do you store encrypted XML as BLOBs/CLOBs in DB?

    However, I will provide the solution which has worked for us many times. So, if one or more endpoints of merge replication fails the following steps must be taken:

    1. Manually add non-synchronized data to all endpoints using tools like Red Gate SQL Data Compare (commercial with free 14-day trial) or free SQL Server Data Tools (SSDT) from Microsoft. The Red Gate's tool is very powerful. You can define custom mappings of tables/columns between databases for comparison. While SSDT from MS at this time can only compare tables having equal names and same schema name. Both tools can generate insert/update/delete scripts to get your data in sync. They even automatically disable and then restore foreign key constraints checks.

    2. Change your publication and set Action if name is in use property to Keep existing object unchanged for all articles.

    3. Reinitialize subscriptions.

    After you perform step #2 and re-init subscription replication agent will still take time to process existing records (and depending on data set size it may take quite some time so think about adding Date filters to articles) but it will not change any data, no deletes or inserts will happen if both publisher and subscriber databases are fully synchronized after step #1. The agent will only mark those existing records as processed to skip them during future runs, so you will only see Update commands counts increased at Replication Monitor. Once subscriptions are reinitialized you should be fine and new data generated at any side will get synchronized.

    Your case is difficult because you can't easily perform manual data sync from step #1. But this is a pre-requisite and you will need to think how to do that. You didn't provide details of how you actually store the encrypted data so I can't suggest the detailed plan but somehow you need to manually decrypt existing XML records, insert missing parts then encrypt again and make sure the encrypted columns are equal at all sides.

    Hope this helps you to resolve your problem.

    PS. I'm not affiliated anyhow neither to Red Gate nor to Microsoft.

    0 讨论(0)
提交回复
热议问题