Documentation : Conflicts

Overview

The concept of conflicts is related with every distributed environments. Simply say - the conflicts arise when several users simultaneously change the same data. 

How it works?

Basically when user is synchronizing its data, Mobeelizer cloud checks if there were any modifications after his last synchronization. If there was any then the entity is not updated. Instead the user is notified that the conflict occurs and the entity is marked as conflicted. Let's examine the following case:

Cloud

User 1

User 2

User 3

Data

Operation

Data

Operation

Data

Operation

Data

A

synchronize

A

synchronize

A

synchronize

A

A

change value

A1

change value

A2

-

A

A1

synchronize

A1

-

A2

-

A

A1*

-

A1

synchronize

A2*

-

A

A1*

synchronize

A1*

-

A2*

synchronize

A1*

A3

resolve coflict

A3

-

A2*

-

A1*

A3

-

A3

synchronize

A3

synchronize

A3

The User 1 and User 2 have changed the value of the same data respectively to A1 and A2. The User 1 has synchronized its data first, so the value of the data on cloud database has been set to A1. Next the User 2 has tried to synchronize. The cloud has noticed that this is a conflict, so the data has been only marked as conflicted. At this point User 2 has in his local database value A2 marked as conflicted.

On cloud database there is value A1, also marked as conflicted. Other user don't know about the conflict. After synchronization User 1 and User 3 have in theirs local database value A1 marked as conflicted. Please notice, that everyone, except the conflict creator, has the last not coflicted data. The resolve conflict operation is basically the update that overwrite all other changes.

What does the conflict resolving type mean?

There are three types of conflict resolving type: manual, overwrite and discard.

Manual type

When conflict is detected every version of conflicted entity is stored. Entity will also be marked as conflicted. Users involved in conflict will see theirs own version of entity. The other user will see the last not conflicted version.

Cloud

User 1

User 2

Data

Operation

Data

Operation

Data

A

synchronize

A

synchronize

A

A

change value

A1

change value

A2

A1

synchronize

A1

-

A2

A1*

-

A1

synchronize

A2*

A1*

synchronize

A1*

-

A2*

Overwrite type

There are no conficts. The new version of entity will always overwrites the old one.

Cloud

User 1

User 2

Data

Operation

Data

Operation

Data

A

synchronize

A

synchronize

A

A

change value

A1

change value

A2

A1

synchronize

A1

-

A2

A2

-

A1

synchronize

A2

A2

synchronize

A2

-

A2

Discard type

There are no conficts. When conflict is detected new version of entity will be ignored.

Cloud

User 1

User 2

Data

Operation

Data

Operation

Data

A

synchronize

A

synchronize

A

A

change value

A1

change value

A2

A1

synchronize

A1

-

A2

A1

-

A1

synchronize

A1

How to resolve the conflict?

To resolve conflict at least one role must have the "resolve conflicts" permission.

Conflict resolving is possible only via HTTP API (as for now). It is simple update operation, but with resolveConflict flag set to true.

{
	"model" : "model name",
	"guid" : "entity's guid",
	"resolveConflict" : "true",
	"fields" : {
		"field1" : "new value of field1",
		...
	}
}

Attachments:

1.png (image/png)
2.png (image/png)