stefan-egli commented on code in PR #1317: URL: https://github.com/apache/jackrabbit-oak/pull/1317#discussion_r1506066095
########## oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java: ########## @@ -354,6 +358,39 @@ private void applyToDocumentStore(RevisionVector baseBranchRevision) boolean commitRootHasChanges = operations.containsKey(commitRootPath); for (UpdateOp op : operations.values()) { NodeDocument.setCommitRoot(op, revision, commitRootDepth); + + // special case for :childOrder updates + if (nodeStore.isChildOrderCleanupEnabled()) { + final Branch localBranch = getBranch(); + if (localBranch != null) { + final NavigableSet<Revision> commits = new TreeSet<>(localBranch.getCommits()); + boolean removePreviousSetOperations = false; + for (Map.Entry<Key, Operation> change : op.getChanges().entrySet()) { + if (":childOrder".equals(change.getKey().getName()) && Operation.Type.SET_MAP_ENTRY == change.getValue().type) { + // we are setting child order, so we should remove previous set operations from the same branch + removePreviousSetOperations = true; + // branch.getCommits contains all revisions of the branch + // including the new one we're about to make + // so don't do a removeMapEntry for that + commits.remove(change.getKey().getRevision().asBranchRevision()); + } + } + if (removePreviousSetOperations) { + if (!commits.isEmpty()) { + int countRemoves = 0; + for (Revision rev : commits.descendingSet()) { + op.removeMapEntry(":childOrder", rev.asTrunkRevision()); + if (++countRemoves >= 256) { Review Comment: deadlock ;) -- 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