Friday 20 November 2009

An update-update conflict between two peers on same node

I recently encountered an error with a peer to peer replication topology between two nodes that drove me near insane trying to solve.

The topology was typical of a peer-peer design in that updates are done on one node only, while reads are done on both, to gain scale out/load balancing benefits. (I had been testing this setup before implementing the final topology which was to horizantally partition the data updates, so that eventually updates were done on both nodes, but records updated on one node were for the first half of the data, and the other node updates for the second half. Reads being done on both still.)

Anyway, while testing the 'updates on 1 node' situation I got this conflict error....

"An update-update conflict between peer 1 (incoming) and peer 1 (on disk) was detected and resolved. The incoming update was skipped by peer 2."

This made no sense as it looks like the conflict was with itself! (ie Peer 1 incoming, and Peer 1 disk)

I tore down the replication many times, checked my code, and did this debugging for a full day without any luck. In the end I went to bed square eyed and disheartened, and woke tired and dissappointed at having wasted the whole previous day and got nowhere to go with the solution. My wife also concerned about my stress bless her.

I popped a message on the priority managed groups (luckily we are a gold partner) and lo and behold MVP Hilary Cotter pointed me to this....

This talks about 'dummy updates' causing problems. Dummy updates?
Well in my case an update statement was along the lines of this
The problem was that COL was already 'ABC' (and so really the update wasn't necessary), but I had not coded for this. Although the update was a valid statement, it sent Replication into a spin.
I hope this saves someone else some pain and anger.

Saturday 14 November 2009

Testing out replication: Two nodes on one box

One thing that is important with replication I feel, is the ability to set it up and have a play. This is the BEST way to learn about all the nuances and magic within this architecture. Things rarely go straight forward with a setup, and I think the pain of going through it only gives you a great wealth of experience when you come out of it the other side

When I first started to have a play, I wanted to make sure that any problems I encountered were elimitated down to SQL server only and not network, permissions or other such red herrings. So I decided to set up 2 instances on one server. Ie an developer edition installation as normal, and then another 'named install' called NODE2 for instance. Then I can replicate back and forth on the same box. This I found very useful to learn. You can set up a named instance by running the normal sqlserver install again, but choose to create 'named instance' along the way during the install wizard.

However, later on I had trouble connecting to NODE2 from client tools on another box, while I could connect to the default instance fine. After much digging I came accross this artice, I recommend it as it helped solve the problem.

Replicating from one node to another is now my standard way to test replication, I recommend it before you start getting multiple servers involved and to get your confidence up.

Sunday 8 November 2009

What is a 'DBA Developer' in the Microsoft world anyway....?

People like to have a title for what they do and DBA is something that has broad scope. I don't think I'm a DBA at all, but I it seems from what I read on the web, lots of the time I'm doing what a DBA might do..whatever a DBA is!

I think i'm probably a 'DBA Developer'.... but what IS that?

In my opinion a 'DBA Developer' is a .NET developer that along the way has fallen into the role of having to roll up sleeves and step from the world of ADO.NET into the one of T-SQL, and has had to learn the hard way, gradually becoming more and more experienced as the years past and have developed a passion for the way SQL Server works. I mean someone who knows both what a DataView is and also knows what a T-SQL nested subquery is.

So in other words, not just backing up databases analysing database growth patterns, but more a .NET developer that has added a good understanding of T-SQL and SQL server experience along the way, knows what an Index is and knows how to profile a query...anyone any thoughts on this? Are you a DBA Developer?

Peer to Peer replication is missing!

When I first started messing around with replication, I looked at a number of the different types, and at the time SQL 2005 had just turned up. It offered a number of replcation types...

Transactional with updateable subscriptions

A great menu for those hungry to replicate, but something else came along aswell, "Peer to Peer replication". Great! at the time this seemed like the correct fit for the project I had in mind. Peer to Peer replication is not obvious to set up and all the tutorials mention that you have to set up 'Transactional' replication and then modify the publication properties (subscription options) to enable 'Allow Peer to Peer subscriptions'. Ok, not a problem, ready for some right click action...lets have a play..I said.

...but for some reason this option to 'Allow Peer to Peer subscriptions' it doesn't appear on my properties dialog...

Then....after much digging I realised that 'Peer to Peer replication' is only available for the Enterprise versions of SQL Server...and my server had 'Standard' installed. Something worth knowing if you are pricing up a setup as the price difference between these two versions is massive. Could leave you with egg on your face when you go back cap in hand to your purchasing department.