Jackrabbit Oak
  1. Jackrabbit Oak
  2. OAK-1290

ObservationManager#removeEventListener prone to deadlocks

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.14
    • Component/s: jcr
    • Labels:

      Description

      The contract for ObservationManager#removeEventListener mandates: "A listener may be deregistered while it is being executed. The deregistration method will block until the listener has completed executing."

      However a strict implementation of this contract is prone to deadlocks: clients unregistering event listeners need to take care not to hold a lock that is also acquired from the event listener being unregistered as this will lead to a deadlock

        Issue Links

          Activity

          Alex Parvulescu made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Hide
          Alex Parvulescu added a comment -

          bulk close for the 0.14 release

          Show
          Alex Parvulescu added a comment - bulk close for the 0.14 release
          Michael Dürig made changes -
          Labels observation
          Michael Dürig made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 0.14 [ 12325549 ]
          Fix Version/s 0.15 [ 12325550 ]
          Resolution Fixed [ 1 ]
          Hide
          Michael Dürig added a comment -

          Fixed at http://svn.apache.org/r1551502.

          Unregistering an observation listener now blocks for no more than one second. If a pending onEvent() call does not complete by then a warning is logged and the listener will be unregistered without further waiting for the pending onEvent() call to complete.

          Show
          Michael Dürig added a comment - Fixed at http://svn.apache.org/r1551502 . Unregistering an observation listener now blocks for no more than one second. If a pending onEvent() call does not complete by then a warning is logged and the listener will be unregistered without further waiting for the pending onEvent() call to complete.
          Hide
          Jukka Zitting added a comment -

          I filed https://java.net/jira/browse/JSR_333-74 with some ideas to avoid this scenario.

          best effort approach

          +1 Sounds good.

          Show
          Jukka Zitting added a comment - I filed https://java.net/jira/browse/JSR_333-74 with some ideas to avoid this scenario. best effort approach +1 Sounds good.
          Michael Dürig made changes -
          Fix Version/s 0.15 [ 12325550 ]
          Hide
          Michael Dürig added a comment -

          As a temporary measure I removed synchronisation at http://svn.apache.org/r1551176 in order to avoid the described deadlock scenario.

          Show
          Michael Dürig added a comment - As a temporary measure I removed synchronisation at http://svn.apache.org/r1551176 in order to avoid the described deadlock scenario.
          Michael Dürig made changes -
          Assignee Michael Dürig [ mduerig ]
          Hide
          Michael Dürig added a comment -

          I suggest to implement a best effort approach to that contract: wait a couple of seconds for the executing event listener to return. If it fails to do so, log a warning and return.

          Show
          Michael Dürig added a comment - I suggest to implement a best effort approach to that contract: wait a couple of seconds for the executing event listener to return. If it fails to do so, log a warning and return.
          Michael Dürig made changes -
          Field Original Value New Value
          Link This issue relates to OAK-1176 [ OAK-1176 ]
          Michael Dürig created issue -

            People

            • Assignee:
              Michael Dürig
              Reporter:
              Michael Dürig
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development