jorgeflorez commented on code in PR #786:
URL: https://github.com/apache/jackrabbit-oak/pull/786#discussion_r1043385190


##########
oak-doc/src/site/markdown/dos_and_donts.md:
##########
@@ -130,3 +130,19 @@ c = d.getParent();                              // 
preferred way to fetch the pa
 this is that Oak internally uses various classes from the `nio` package that 
implement 
 `InterruptibleChannel`, which are [asynchronously 
closed](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/channels/InterruptibleChannel.html)
 
 when receiving an `InterruptedException` while blocked on IO. See 
[OAK-2609](https://issues.apache.org/jira/browse/OAK-2609).  
+
+### Avoid or minimize conflicts
+To reduce the possiblity of having errors like `OakState0001: Unresolved 
conflicts in ...`:
+
+1. Try to keep the JCR sessions as short as possible. i.e. create the session, 
make your changes, call session.save() and then session.logout(). If you need 
to do 
+something additional in the repository, a few lines after (maybe after some 
processing that could take some time), create the session again and repeat.
+
+2. Try to use session.refresh(true) before saving, if you think that some 
significant time can pass between the login() and the save() call.
+
+3. Enable the DEBUG level for 
`org.apache.jackrabbit.oak.plugins.commit.MergingNodeStateDiff` and 
`org.apache.jackrabbit.oak.plugins.commit.ConflictValidator` loggers if you 
want 
+to have more information on the circumstances of a conflict that happened in a 
point of time.
+
+4. Write your own conflict handler and add it when configuring your Oak or 
WhiteBoard instances. Only if you know what you are doing (i.e. you know how to 
resolve 
+the conflict in each one of the possible situations). By default, the 
[AnnotatingConflictHandler](https://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/plugins/commit/AnnotatingConflictHandler.html)
 instance will discard your changes 
+and your commit will fail. The worst that will happen is that your changes 
will not be saved (if you are ok with that).
+Please check the source code of 
[JcrLastModifiedConflictHandler](https://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/plugins/commit/JcrLastModifiedConflictHandler.html).
 It seems like a good example to follow.

Review Comment:
   Hi @anchela, I think I got all changes you wanted. If I understood correctly 
this workflow, you can now view them :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to