Question

Does anybody know of a design pattern that tackles the complexity of synchronising two identical relational databases? I keep running into this challenge on various projects and can't find a suitable pattern that deals with it in depth. The specific challenges that I am facing are:

  • Ordering of tables and records which are dependant upon each other, especially where there are two tables that each have a foreign key reference to one another
  • Ensuring that both models are consistent
  • Concurrency where users of one model are writing to a model that is busy being updated by a sync session
  • Minimising overhead where the knowledge of a change is fake and, while an update has been performed, the data hasn't changed
  • Row versioning, leading from the previous point, row versioning using a rowversion or timestamp column updates the row version during an update even if no data has changed.
  • Rolling back from an exception during a sync session

If anybody knows of a pattern, or even a stack, that tackles these challenges, I would love to hear your thoughts. I have tried using MS Sync Framework and while it does address many of the issues involved in data synchronisation, it isn't a complete solution in terms of the challenges listed above.

Was it helpful?

Solution

Please check the

Master-Master Row-Level Synchronization

Context

You are about to design a replication between a source and a target, as described in Master-Master Replication. Your requirements are:

The replication set is updateable at either end of the replication.

Updates need to be transmitted to the other party.

Conflicts need to be detected and resolved at defined points in time, following defined data integrity rules.

Potential conflicts in the changes are to be resolved at the row level.

Solution

Create a pair of related replication links between the source and target as described in the Master-Master Replication pattern. Additionally, create a synchronization controller to manage the synchronization and connect the links. This solution describes the function of one of these replication links. The other replication link behaves the same way, but in the opposite direction. To synchronize more than two copies of the replication set, create the appropriate replication link pair for each additional copy.

 Hint: When designing the replication link, it is important to know what types of conflicts can occur and how to handle them so that the integrity of replicated data remains intact. The design of conflict detection and conflict resolution is described in the Master-Master Replication pattern.

enter image description here

More data movemevent patterns on:

Data Movement Patterns

OTHER TIPS

First of all check this.

A very interesting blog about design patterns is also this.

As far as concerning your specific challenges, considering you can run on MS SQL, running Sync Framework can guarantee, at least the following:

  • Ensuring that both models are consistent

  • Concurrency where users of one model are writing to a model that is busy being updated by a sync

  • session Rolling back from an exception during a sync session

If you are interested on MS Sync Framework have a look here

Check liquibase. It is tool that will help you to work with the database in a more repository friendly way. And it supports SQL Server with no issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top