Cluster & CoreSession.setLock(…) [5.6]
Hi,
I have two back-end servers on a single nuxeo‑5.6 repository with concurrent scheduled import jobs running. To avoid concurrent document creation, I use a try {} catch {} block and set a document lock on a common parent document :
try {
/* … */
session.setLock(parentDocument.getRef());
/* … */
/* do multiple documents creation */
} finally {
session.removeLock(parentDocument.getRef());
}
It did worked fine… until today, two concurrent document creation occurred.
So is CoreSession#setLock(DocumentRef ref)
a good way of handling mutual exclusion between servers ? Is there a good (or more atomic) way of writing cluster-safe process ?
Cheers, Léa Raya DÉCORNOD
This should work but 5.6 is a quite old Nuxeo version so we can't rule out locking bugs at this stage. Without a reproducible test case there's little hope to get to the bottom of this.
The forthcoming Nuxeo State Manager, described in NXP-14553, will likely provide the ultimate solution to the issue you described. If you can't wait, you might consider adding a uniqueness constraint on specific columns in the hierarchy table as described in NXP-16912 and then writing some fairly low-level Java code to enforce unique pathSegments for children within a single Folderish document.