Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

DB Mirroring and Initialize from LSN doesn't work Expand / Collapse
Author
Message
Posted Friday, June 14, 2013 4:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 24, 2013 9:13 AM
Points: 4, Visits: 51
Hi everyone first post here so please go easy, always used this site for it's great resources but now require some help! :)

For some reason we cannot initialize from LSN in a mirrored setup.

We have 3 servers and push replicate from A to B, SRVB and SRVC are setup with database mirroring.

SRVA – Publisher

SRVB – Principal

SRVC – Mirror

Basically We have followed the MS document (http://go.microsoft.com/fwlink/?LinkId=213051) that is hyperlinked from this webpage http://msdn.microsoft.com/en-GB/library/ms151799.aspx

In the document it contradicts itself saying that we shouldn’t allow the ‘Allow initialization from backup files’ option but then later in the document it says that we should allow this in order to initialize from LSN ??

So to test this replication was running, I manually failed over B to C.

On C I ran the code below to get the latest LSN,

SELECT transaction_timestamp, *

FROM dbo.MSreplication_subscriptions

WHERE publisher = ‘xxxxxxxx’

AND publisher_db = 'xxxxxxx'

AND publication = 'xxxxxxxx';

Once I had the transaction_timestamp I went back over to the Publisher server (SRVA) and ran the below using the transaction_timestamp I got from the previous step

EXEC sp_addsubscription

@publication = N'xxxxxxxxx',

@subscriber = N'xxxxxxxx',--This needs to be set to the new subscriber/what you have just failed over to.

@destination_db = N'xxxxxxxxxxx',

@subscription_type = N'push',

@sync_type = N'initialize from LSN',

@article = N'all',

@update_mode = N'read only',

@subscriber_type = 0,

@subscriptionlsn = 0x0001D3FC0000030B0001000000000000


exec sp_addpushsubscription_agent

@publication = N'xxxxxxxxxxxx',

@subscriber = N'xxxxxxxxxxx',--This needs to be set to the new subscriber/what you have just failed over to

@subscriber_db = N'xxxxxxxxx',

@subscriber_security_mode = 0,

@subscriber_login = N'xxxxxx',

@subscriber_password = N'xxxxxxxxxxxxxx',

@frequency_type = 64,

@frequency_interval = 1,

@frequency_relative_interval = 1,

@frequency_recurrence_factor = 0,

@frequency_subday = 4,

@frequency_subday_interval = 5,

@active_start_time_of_day = 0,

@active_end_time_of_day = 235959,

@active_start_date = 0,

@active_end_date = 0,

@dts_package_location = N'Distributor'

GO

So when doing that we originally got the error about allowing to init from backup so we set that to true as the document was contradicting itself, when running the above it then produced this error.

The transactions required for synchronizing the subscription with the specified log sequence number (LSN) are unavailable at the Distributor. Specify a higher LSN.

Does anyone know if we did something wrong here? The next step would have been to drop the previous subscription but we didn’t get that far, just a little worrying that we followed the MS whitepaper but it didn’t work.

Any help is appreciated, thanks.
Post #1463476
Posted Wednesday, July 3, 2013 5:30 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, October 3, 2014 1:55 PM
Points: 199, Visits: 735
Hi,

same problem here but no solution too :-(

At least I can commit that there might be something wrong with Microsoft's whitepapers.

I have an Always On Group on SQL 2012, getting it's data via replication from a SQL 2008 R2.
In the case of a failover the whitepaper tells us to create a subscription on the new primary node and use the lsn taken from MSreplication_subscriptions for initializing. I'm getting the same error.
Post #1470001
Posted Wednesday, July 3, 2013 7:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 24, 2013 9:13 AM
Points: 4, Visits: 51
Agreed!

We were in that position before, we removed AG to cut on costs and then went to a mirrored solution on standard edition.

No one seems to want to touch this with a barge pole and some mods over at msdn said they'd get back to me but haven't
Post #1470031
Posted Wednesday, July 3, 2013 7:30 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, October 3, 2014 1:55 PM
Points: 199, Visits: 735
I think I have bad news I found this note in books online (/http://technet.microsoft.com/en-us/library/ms151705.aspx):
When restoring a backup, you must ensure that the backup came from the Publisher if you want the Subscriber to automatically synchronize. The log sequence number (LSN) values in the backup (which are used to set the point at which to start synchronizing) are specific to the Publisher.

It's for SQL 2012 but I'm sure it's the same for 2008(R2)

I'm not sure but I think it means:
You HAVE to create the subscription database using a backup so that the LSNs between publisher and subscriber can be matched.
In my case, I created a new database on the subscriber and pushed a new snapshot.
When now using the LSN to initialize the new subscription it won't be found on the publisher. Never. This means that the way of initializing using a LSN simply does not and will not work for my subscribers

Are there other opinions about this note? Or is this note independent of using LSN and only valid for really initializing using backups?
Post #1470049
Posted Thursday, July 4, 2013 1:12 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, October 3, 2014 1:55 PM
Points: 199, Visits: 735
I did some testing and figured it out.
It does not matter if you initialized the subscribers using restore a database, snapshot or whatever.

As we know: initializing the subscription using initialize from LSN needs the publication property allow_initialize_from_backup set to true.

BUT:
You have to set the allow_initialize_from_backup-option before creating the subscription(s)!
If the option is set to false when creating the subscriptions, you can change the option afterwards but initializing using LSN just won't work.

Now I have 2 questions:
1) Books online says when setting allow_initialize_from_backup to true, you should set immediate_sync to true too. Why? I neet the immediate sync to false when adding new articles! What are the consequences?
2) Does this really mean that I have to reinitialize my subscriptions just to be ready for a failover?

hmmmm......
Post #1470327
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse