Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Projects

Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

This page is based on 'Conflict detection and resolution - research'.

Introduction

Conflict scenarios:

  • Update-update
    Occurs when the same object was updated at more than one node.
  • Update-delete
    Occurs if a row was updated at one node, but the same row was deleted at another node.
  • Delete-delete
    Occurs when a row was deleted from more than one node.

Conflict Detection

Conflict detection is based on hash codes. Every object has its own Sync hash code which can be generated basing on that object. During pull or push operation a child instance compares hash codes of a local object, parent's object and recently saved parent's object. The hash code of recently saved parent's object is persisted in the database. We have to establish some shortcuts before we explain when the conflict is detected:

  • #C : a hash code of the child instance object
  • #P : a hash code of the parent instance object
  • #lastP : a last saved hash code of the parent instance object.

The conflict is detected when (#lastP != #P) && (#C != #P).

Note! We have added a new row in a database sync_parent_object_hashcode table for each object pulled  from its Parent instance. We keep only the most current hash code of each object.


Conflict Resolution

Conflict resolution can be handled automatically or manually. After the conflict is detected it is passed to object/service which implements MergeBehaviour interface. The MergeBehaviour class defines a strategy of dealing with conflicts automatically. (In fact, you can add your own implementation. All hints can be found here.) All unresolved conflicts will be saved in order to be solved by the users. 

If the same object causes another conflict, then an old one will be replaced with the new one. So there is only one, the most recent, conflict regarding any object.


  • No labels