0

In one of the lotus notes db, too frequent replication/save conflicts are caused reason being a scheduled agent and any user working on the document at the same time.

is there any way to avoid this.

Thanks, H.P.

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
Himanshu.MarJAVA
  • 475
  • 1
  • 11
  • 33

5 Answers5

2

Several options in addition to merging conflicts:

Change the schedule The best way to avoid it is to have your scheduled agents running at times when users are not likely to be accessing the system. If the LastContact field on a Client document is updated by an agent every hour as it checks all Contact documents, maybe the agent should run overnight instead.

Run the agent on user action It may also be the case that the agent shouldn't be running on a schedule, but should be running when the user takes some action. For example, run the agent to update the Client document when the user saves the supporting Contact document.

Break the form into smaller bits A third thing to consider is redesigning your form so that not every piece of data is on a main form. For example, if comments on recent contacts with a client are currently held in a field on the Client document, you might change the design to have a separate ClientMeeting form from which the comments on the meeting are displayed in an embedded view or computed text (or designed using Xpages).

Despite the fact that I am a developer, I think rep/saves are far more often the result of design decisions than anything else.

David Navarre
  • 1,022
  • 10
  • 27
  • Use document locking? http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_LOCKING_A_DOCUMENT_OVER.html – leyrer Jul 28 '12 at 11:50
  • I agree with @David's conclusion, see if you can redesign that part of the application. – D.Bugger Jul 29 '12 at 08:58
  • @leyrer I think the issue is more fundamental than document locking is intended to resolve. The OP is having problems when an agent tries to modify the document at the same time as it is being edited manually. So, while document locking might avoid the conflict by delaying the agent's modification of the document, the real problem is that the agent wants to modify the document at the same time as the user. – David Navarre Jul 30 '12 at 13:47
  • Conidering the design part, We are using version 6.5, and I see no way to keep data separate in two different forms, and still be made available to user in a single form. – Himanshu.MarJAVA Aug 06 '12 at 13:19
  • Had embedded views or computed text been included in 6.5? There will at least be computed for display fields. Forms don't have to display information from only one document - DbLookup is your friend. So, there are probably ways to display it all to the user on one screen. – David Navarre Aug 06 '12 at 15:50
0

You can use the Conflict Handling option on the form(s) in question and select either Merge Conflicts or Merge/No Conflicts in order to have Notes handle merging of edit conflicts.

From the Help database:

At the "Conflict Handling" section of the Form Info tab, choose one of the following options for the form:
Create Conflicts -- Creates conflicts so that a replication conflict appears as a response document to the main document. The main document is selected based on the time and date of the changes and an internal document sequence number.
Merge Conflicts -- If a replication conflict occurs, saves the edits to each field in a single document. However, if two users edit the same field in the same document, Notes saves one document as a main document and the other document as a response document marked as a replication conflict. The main document is selected based on the criteria listed in the bullet above.
Merge/No Conflicts -- If replication occurs, saves the edits to each field in a single document.  If two users edit the same field in the same document, Notes selects the field from the main document, based on time and date, and an internal document sequence number. No conflict document is generated, instead conflicting documents are merged into a single document at the field level.
Do Not Create Conflicts -- No merge occurs. IBM® Lotus® Domino(TM) simply chooses one document over another. The other document is lost.
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • Conflict handling does not help with save conflicts, so this would only help if the user access and the agent execution are on different servers. (Or if the user is working in a local replica.) And for an existing application, you also have to add the $ConflictAction item to all existing documents and replicate that change across all servers (and/or to all local replicas) before it really starts to help. – Richard Schwartz Jul 26 '12 at 15:30
  • we already have Merge Conflicts selected in option and still conflicts are created – Himanshu.MarJAVA Aug 06 '12 at 13:20
0

In later versions of Notes there is the concept of document locking, and used properly that can prevent conflicts (but also add complexity).

Usually most conflicts can be avoided by planning to run the agents late at night when users aren't on the system. If that's not an option, then locking may be the best solution. If the conflicts aren't too many, you might benefit from adding a view filtered to show only conflicts, which would make findind and resolving them easier.

Ken Pespisa
  • 21,989
  • 3
  • 55
  • 63
  • The view has already beenc created to display conflicts, But the question here is to find the solution, so that conflicts are not created at all. – Himanshu.MarJAVA Aug 06 '12 at 13:23
0

IMHO, the best answer to conflicts between users and agents is to make sure that they are operating on different documents. I.e., there are two documents with a common key. They can be parent and child if it would be convenient to show them that way in a view, but they don't have to be. Just call them DocA and DocB for the purposes of this discussion.

DocA is read and updated by users. When a user is viewing DocA, computed field formulas can pull information from DocB via DbLookup or GetDocField. Users never update DocB.

DocB, on the other hand, is read and updated by agents, but agents only read DocA. They never update them.

If you design your application any other way, then you either have to use locking -- which can create the possibility of not being able to update something when you need to, or accepting the fact that conflicts can happen occasionally and will need to be resolved.

Note that even with this strategy, you can still have conflicts if you have multiple replicas of the database. You can use the 'Conflict Handling' section of the Form properties to help minimize replication conflicts, as per @Per Henrik Lausten's answer, but since you are talking about an existing please also see my comment to his answer for additional info about what you would have to do in order to use this feature.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
0

If this is a mission critical application, consider creating a database with lock-documents. That means, every time a user opens a document, a separate lock-document is created.

Then code the agent to see if lock-documents exist for every document that the agent wants to modify. If it does, skip that document.

Document-close should remove the doc-lock.

The lock-doc should be created on document open, not just read. This way, when a user has the document open in read mode, the agent will not be able to modify as well. This is to prohibit, that the user might change to editmode afterwards and make changes.

If the agent has a long modification time, it should create lock-docs as well.

Jörg Asmussen
  • 339
  • 2
  • 10
  • Why not do the locking and checking for locks only when the user either opens in edit mode or changes to edit mode? – David Navarre Aug 16 '12 at 14:30
  • This is a good workaround. But cant we check in our agent if document is opened for editing? – Himanshu.MarJAVA Jul 10 '13 at 19:30
  • Also will it help when I use lock and unlock method in the agent while updating these documents – Himanshu.MarJAVA Jul 10 '13 at 19:40
  • @Himanshu: Well you will probably have to write a little LotusScript and/or Java class/api, to call within your collection loops. The lock documents would use NotesDocument.UniversalID as reference, and the agent would use the same value as a key to check into the lock database. And yes, you can use the same method the other way round. The agent creates a lock, and the NotesDocument.QueryOpen event should check for locks. But beware, this will also prevent multiple users from opening the same document. This might be a desired feature though, which I have seen in a call center application. – Jörg Asmussen Aug 09 '13 at 22:00
  • @DavidNavarre: I am not 100% sure about this, but the chance is, that the document opened in edit mode is the same as the in memory revision used for read mode. I don't think the "ModeChange" triggers a reload of the document from the server. This way, when the agent has edited the server version of the document, while the user was in read mode, the user might do changes in edit mode, but is not able to save it due to a "Document has changed" error. So it's to prevent the user from getting disappointed and loosing edits – Jörg Asmussen Aug 09 '13 at 22:22