As I have already discussed that In Lotus database, the same document in one copy of a database or in different replicas between replication sessions, can be edited by multiple users simultaneously.
For a deep insight about Replication or Save conflicts in Lotus Notes, go to my previous blog post entitled, “how to deal with Replication or Save conflicts in Lotus Notes”.
In current post, I am going to discuss the methods for conflict handling and ways to avoid conflicts.
Whenever a conflict occurs you can view your winner (main document) and looser conflict documents (response documents) that will be listed in the document column headers as Document 01 (Winner), Document 02 (Looser) etc. Right click the document-column headers to open the document context menu.
While resolving the replication or save conflicts in Lotus Notes the List Fields provides you to options:
The two menu items are:
- Show this document in Notes.
- Set this document as "Replication- or Save conflict" winner.
• Show this document in Notes. If you select the first option, it will launch the Lotus Notes document that is currently selected.
• Set this document as "Replication- or Save conflict" winner. If you will choose this list item then, the currently selected document is forced to be the winner among other conflict-documents and it will delete rest other documents participating in the conflict.
How to avoid replication or save conflicts
There can be two ways to deal with it:
1. Save Conflict can occur if the database is residing on a single a server and multiple users are accessing it so, its better to apply document locking in such case.
If the document is already open in editing mode then a lock will be implemented on it, and if some other user tries to open it for editing at that time then, the logic will restrict his access and will be informed that currently the document is being edited by some other user.
Once the current user finishes with document editing process, the document lock will be removed thus allowing other user to edit it.
2. But the case would be different from the above if the same document is shared between multiple servers .In such a replication conflict could occur if a user or server edits the same document. This locking concept will fail because the replica copies of the database are not aware of each other.
The best way to avoid this is by reducing the number of simultaneous access to the document. This can be done my limiting the access to the documents of different Readers- and Authors and keeping a consistent ACL (Access Control List) on the replica copies.
When you select File - Replication - New Replica, then a replica stub( an empty replica ) is created.
You can choose to populate this replica immediately with documents or can populate it at the next scheduled replication.
It can happen that you didn’t copy the ACL but still the new replica contains the ACL of the source server either if the ACL has been modified by someone before initial replication or there might be some synchronization issue with the server.
Avoid replication conflicts with the help of the database designer:
• Notes offers you several options to handle if a conflict occurs. The database designer allows you to enable the merge conflict menu item from the Form Properties.
By enabling this property Domino will automatically resolve the conflicts that have the differences are in different fields.
• The database designer allows you to enable versioning so that if a document is saved then a new version is created for each document.
How to prevent the conflict document from occuring?
- The conflicts are stored as $ConflictAction item in the Domino document. Lotus offers different form options for dealing with the conflicts.
- Whenever a document conflict occurs Lotus determines the "winner" and "loser" document.
- The document that is most edited is designated as the winner document.
- If all conflict documents are edited same number of times then the document that is saved last is designated as the winner document.
After determining the “winner" and "loser" document, Domino then, executes the conflict resolution procedure as follows:
• Create conflicts (no $ConflictAction item)
In this case the loser document is designated as Response document to the winner document (main document) and an item $Conflict is created
• Merge conflicts ($ConflictAction = "1")
If a document is being edited concurrently but the fields altered in each edit is different, then to avoid conflicts they are merged into a single document. If the same fields are altered a conflict is still generated.
• Merge/No Conflicts ($ConflictAction = "3")
If different fields in a document are altered then the documents are merged into in single document. But if the same fields are altered then, the loser document is deleted; only main document is kept in the database.
• No Conflicts ($ConflictAction = "2")
In this case the looser document is simply discarded and only winner is kept.
How to prevent Replication and Save" conflicts on the same server?
• If documents are on same server then its better to apply document locking to prevent Replication and Save" conflicts.
• You must always ensure that you aren’t running your scheduled agent on two servers concurrently
• Don’t use NotesDocument.save(...) in a querySave (or postSave without closing the form) event.
• Always keep track of your application flow to limit the current allowed editor with the help of Author fields/items. You can remove access in querySave and an agent altering access "on documents changed”.
• Check your forms: are there fields that are "computed" and changed by agents? You could/should set them to "computed" and changed by agents
• All Those forms fields that are "computed" and changed by agents, set them to "computed" and changed by agents
• Use NotesDocument.computeWithForm(..) in agents only if you are sure that its the conflict source otherwise strictly avoid it .
• You should implement the inversion of logging pattern if you are having multiple concurrent edits
• You should cluster your servers and avoid replication.
I hope this post will help you to deal with replication or save conflicts in Lotus Notes.To know more about,”document locking procedure in Lotus Notes” read my upcoming article. You comments and feedback are most welcome.