Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-2411

Upgrade may fail with constraint exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0.9, 1.1.4
    • 1.0.10, 1.1.5
    • core
    • None

    Description

      A repository upgrade to MongoMK sometimes fails with a constraint exception in PrivilegeValidator.childNodeChanged():

      18074 [main] ERROR org.apache.jackrabbit.oak.security.user.UserInitializer - Failed to initialize user content.
      org.apache.jackrabbit.oak.api.CommitFailedException: OakConstraint0041: Attempt to modify existing privilege definition jcr:nodeTypeManagement
      	at org.apache.jackrabbit.oak.security.privilege.PrivilegeValidator.childNodeChanged(PrivilegeValidator.java:109)
      	at org.apache.jackrabbit.oak.security.privilege.PrivilegeValidator.childNodeChanged(PrivilegeValidator.java:47)
      	at org.apache.jackrabbit.oak.spi.commit.EditorDiff.childNodeChanged(EditorDiff.java:143)
      	at org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState.compareAgainstBaseState(MemoryNodeState.java:155)
      

      The problem is related to the way NodeStateDiff.childNodeChanged() is specified:

      Called for all child nodes that may contain changes between the before and after states. The comparison implementation is expected to make an effort to avoid calling this method on child nodes under which nothing has changed.

      When the upgrade runs, PriviledgeValidator.childNodeChanged() is called even though there isn't actually a difference between the before and after state.

      On merge() the MemoryNodeStore squeezes the current NodeState (in MemoryNodeStoreBranch.setRoot()). This operation turns ModifiedNodeStates into equivalent MemoryNodeStates. When the hooks later process the changes, the node state comparison happens for a state that was squeezed with one that wasn't. This leads to MemoryNodeState.compareAgainstBaseState() calls where after != before and therefore diff.childNodeChanged() is called, even though the actual data of the states are equal.

      Attachments

        Issue Links

          Activity

            People

              mreutegg Marcel Reutegger
              mreutegg Marcel Reutegger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: