We have a transactional replication setup. The publisher is on a separate SQL Server and the distributor and the subscriber together on the other server. The replication was done using restore from backup from the publisher.
Now, I have to make my subscriber database as my main database, which will also be my publisher. And the server that have my current publisher database will now be my subscriber. I have several websites using the database said. I stopped the replication agent and tried to 'point' the websites in the subscriber.
However, insert commands are failing on my subscriber (even after stopping replication) with errors relating to primary keys which is also set as auto-increment. I checked the table schema in the subscriber database and the auto increment as well as the identity specification for that certain column is set to yes.
My question is what are the changes need to be done if I want my current subscriber to be a publisher (or main database for that matter)? Will i need to take backup again from my new publisher if I will make a subscriber from my old publisher database?
If it helps, our current database is now 100 GB in size. There is a table having 40m records and changing a schema, to drop and and recreate the whole table 'may' not be an ideal option for us now.
Best Answer
Best option for you will be to reestablish replication with reverse role but avoid a full snapshot and re-sync to minimize downtime. I will outline high level steps here and if you need further details let me know.
Once downtime start (confirm app servers are not making any new connection/writing to publishing articles):
Add remote distributor to new publisher if it is a separate instance (old subscriber).
Reinstall replication with 'replication support only' when running
sp_addsubscription
. See details here.You can use this query to find undelivered commands in distribution database.