I have some code which has been working flawlessly for a long time for getting sequence numbers, but with oak 1.2.2 it's started throwing exceptions. I am wondering if there's a way to use the org.apache.jackrabbit.util.Locked class so that it will not throw exceptions, when used with oak and the different session isolation configuration it has compared to jackrabbit 2.8.*?
javax.jcr.RepositoryException: Unable to unlock node /ka:system/ka:counter at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.unlock(NodeDelegate.java:837) at org.apache.jackrabbit.oak.jcr.lock.LockManagerImpl$8.perform(LockManagerImpl.java:176) at org.apache.jackrabbit.oak.jcr.lock.LockManagerImpl$8.perform(LockManagerImpl.java:170) at org.apache.jackrabbit.oak.jcr.lock.LockOperation.perform(LockOperation.java:68) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:216) at org.apache.jackrabbit.oak.jcr.lock.LockManagerImpl.perform(LockManagerImpl.java:214) at org.apache.jackrabbit.oak.jcr.lock.LockManagerImpl.unlock(LockManagerImpl.java:170) at org.apache.jackrabbit.util.Locked.runAndUnlock(Locked.java:280) at org.apache.jackrabbit.util.Locked.with(Locked.java:195) at org.apache.jackrabbit.util.Locked.with(Locked.java:124) at org.apache.jackrabbit.util.Locked.with(Locked.java:103) at no.xx. content.services.repository.RepositoryService.getNewSerialNumber(RepositoryService.java:230) [...] then Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakState0001: Unresolved conflicts in /ka:system/ka:counter at org.apache.jackrabbit.oak.plugins.commit.ConflictValidator.failOnMergeConflict(ConflictValidator.java:84) at org.apache.jackrabbit.oak.plugins.commit.ConflictValidator.propertyChanged(ConflictValidator.java:60) at org.apache.jackrabbit.oak.spi.commit.CompositeEditor.propertyChanged(CompositeEditor.java:91) at org.apache.jackrabbit.oak.spi.commit.EditorDiff.propertyChanged(EditorDiff.java:93) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState.compareProperties(SegmentNodeState.java:596) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:456) at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:148) at org.apache.jackrabbit.oak.plugins.segment.MapRecord.compare(MapRecord.java:418) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:583) at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:148) at org.apache.jackrabbit.oak.plugins.segment.MapRecord.compare(MapRecord.java:418) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeState.compareAgainstBaseState(SegmentNodeState.java:583) at org.apache.jackrabbit.oak.spi.commit.EditorDiff.process(EditorDiff.java:52) at org.apache.jackrabbit.oak.spi.commit.EditorHook.processCommit(EditorHook.java:54) at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:61) at org.apache.jackrabbit.oak.spi.commit.CompositeHook.processCommit(CompositeHook.java:61) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore$Commit.prepare(SegmentNodeStore.java:405) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore$Commit.optimisticMerge(SegmentNodeStore.java:428) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore$Commit.execute(SegmentNodeStore.java:484) at org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore.merge(SegmentNodeStore.java:162) at org.apache.jackrabbit.oak.core.MutableRoot.commit(MutableRoot.java:247) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.commit(SessionDelegate.java:313) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.commit(SessionDelegate.java:338) at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.unlock(NodeDelegate.java:831) ... 114 more 13:19:22,066 WARN o.a.j.o.j.s.SessionContext.perform() l: 397 [127.0.0.1] Failed to unlock a session scoped lock javax.jcr.lock.LockException: Node /ka:system/ka:counter is not locked at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.unlock(NodeDelegate.java:825) at org.apache.jackrabbit.oak.jcr.session.SessionContext$1.perform(SessionContext.java:395) at org.apache.jackrabbit.oak.jcr.session.SessionContext$1.perform(SessionContext.java:387) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:216) at org.apache.jackrabbit.oak.jcr.session.SessionContext.unlockAllSessionScopedLocks(SessionContext.java:387) at org.apache.jackrabbit.oak.jcr.session.SessionContext.dispose(SessionContext.java:369) at org.apache.jackrabbit.oak.jcr.session.SessionImpl$10.perform(SessionImpl.java:481) at org.apache.jackrabbit.oak.jcr.session.SessionImpl$10.perform(SessionImpl.java:478) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:216) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.safePerform(SessionDelegate.java:262) at org.apache.jackrabbit.oak.jcr.session.SessionImpl.safePerform(SessionImpl.java:145) at org.apache.jackrabbit.oak.jcr.session.SessionImpl.logout(SessionImpl.java:478) at no.karriere.content.services.repository.RepositoryService.getNewSerialNumber(RepositoryService.java:237) The node has node type oak:Unstructured, with a mix:lockable mixin and a value property. Session session = null; try { session = getSession(); Node root = session.getRootNode(); Node counter = root.getNode(NODENAME_SYSTEM+"/" + serialName); long nextValue = ((Long) new Locked() { @Override protected Object run(Node counter) throws javax.jcr.RepositoryException { Property seqProp = counter.getProperty("value"); long value = seqProp.getLong(); seqProp.setValue(++value); seqProp.save(); return new Long(value); } }.with(counter, false)).longValue(); return (int) nextValue; } catch (Exception e) { log.error("unable to get new serial; ", e); } finally { if (session != null) { session.logout(); } } -- -Tor