You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Thomas Mueller (JIRA)" <ji...@apache.org> on 2012/08/08 12:18:09 UTC

[jira] [Created] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Thomas Mueller created JCR-3406:
-----------------------------------

             Summary: Journal doUnlock sometimes not called on repository shutdown
                 Key: JCR-3406
                 URL: https://issues.apache.org/jira/browse/JCR-3406
             Project: Jackrabbit Content Repository
          Issue Type: Improvement
            Reporter: Thomas Mueller
            Assignee: Thomas Mueller


When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.

The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.

To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Reopened] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Marcel Reutegger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcel Reutegger reopened JCR-3406:
-----------------------------------

    
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 2.6
>
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13434059#comment-13434059 ] 

Thomas Mueller commented on JCR-3406:
-------------------------------------

Hi,

I found the Journal.close() method is sometimes called before unlocking, so I guess your solution could still prevent unlocking if events are processed while the node is stopping. So I suggest to remove the "if" statement unless we have a strong reason to keep it (if possible a test case).

Regards,
Thomas

                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13431101#comment-13431101 ] 

Thomas Mueller commented on JCR-3406:
-------------------------------------

Proposed patch:

{code}
Index: src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java	(revision 1370130)
+++ src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java	(working copy)
@@ -665,10 +665,6 @@
          * {@inheritDoc}
          */
         public void updateCommitted(Update update, String path) {
-            if (status != STARTED) {
-                log.info("not started: update commit ignored.");
-                return;
-            }
             Record record = (Record) update.getAttribute(ATTRIBUTE_RECORD);
             if (record == null) {
                 String msg = "No record prepared.";
@@ -705,10 +701,6 @@
          * {@inheritDoc}
          */
         public void updateCancelled(Update update) {
-            if (status != STARTED) {
-                log.info("not started: update cancel ignored.");
-                return;
-            }
             Record record = (Record) update.getAttribute(ATTRIBUTE_RECORD);
             if (record != null) {
                 record.cancelUpdate();
{code}
                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Marcel Reutegger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcel Reutegger updated JCR-3406:
----------------------------------

    Fix Version/s:     (was: 2.6)
                   2.5.2
    
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 2.5.2
>
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Marcel Reutegger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13444162#comment-13444162 ] 

Marcel Reutegger edited comment on JCR-3406 at 8/30/12 3:23 AM:
----------------------------------------------------------------

This change produces warnings on startup. It would be better to also consider the record attribute:

29.08.2012 16:38:10 *WARN * [main] ClusterNode: No record prepared. (ClusterNode.java, line 672)

                
      was (Author: mreutegg):
    This change produces warnings on startup. It would be better to also consider the record attribute.
                  
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 2.6
>
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Mueller resolved JCR-3406.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.6
    
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 2.6
>
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Marcel Reutegger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcel Reutegger resolved JCR-3406.
-----------------------------------

    Resolution: Fixed

Fixed in revision: 1378878
                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 2.6
>
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13434890#comment-13434890 ] 

Thomas Mueller commented on JCR-3406:
-------------------------------------

Please note the patch only applies to updateCancelled and updateCommitted. As far as I see, those methods are called after updateCreated / updatePrepared, and those two methods do test for status == STARTED (I didn't change that). So I don't see how this could affect startup, but I might be wrong of course.

> I'm just afraid we might create some race condition on startup. The code seems to be designed to first trigger a sync() call before any other operations are done which seems correct to me. 

Sorry I don't understand, the patch I made doesn't affect sync() as far as I see. It is only supposed to ensure that the journal is unlocked if it was locked.

It's quite hard to say if the patch would break something, just on a theoretical basis (without test cases). I do have an upstream test case that shows the current behavior is problematic, and the patch fixes that, so I suggest I will commit my patch next week, unless somebody can come up with a better patch, or a test case that shows my patch is problematic.

                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Bart van der Schans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13434121#comment-13434121 ] 

Bart van der Schans commented on JCR-3406:
------------------------------------------

The if statements seem to be part of the original implementation of JCR-623. I'm just afraid we might create some race condition on startup. The code seems to be  designed to first trigger a sync() call before any other operations are done which seems correct to me.

So I rather add some extra logic to the Journal.close() and/or repository shutdown to unlock properly than removing this "safeguard".

Bart
                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Marcel Reutegger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13444162#comment-13444162 ] 

Marcel Reutegger commented on JCR-3406:
---------------------------------------

This change produces warnings on startup. It would be better to also consider the record attribute.
                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>             Fix For: 2.6
>
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Bart van der Schans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13431720#comment-13431720 ] 

Bart van der Schans commented on JCR-3406:
------------------------------------------

I'm not sure if the STARTED check is really needed (may somebody else knows?). We might want to keep it in place and instead change the check?

Maybe something like:

if (status != STARTED && status != STOPPED)

This still would prevent a run in the NONE (initial) status. When the final run is done we might want to set the status back to NONE or to CLOSED.

Bart
                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3406) Journal doUnlock sometimes not called on repository shutdown

Posted by "Bart van der Schans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13434956#comment-13434956 ] 

Bart van der Schans commented on JCR-3406:
------------------------------------------

Ok, sounds fine to me.
                
> Journal doUnlock sometimes not called on repository shutdown
> ------------------------------------------------------------
>
>                 Key: JCR-3406
>                 URL: https://issues.apache.org/jira/browse/JCR-3406
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>
> When the repository is shut down, the method AbstractJournal.doUnlock(boolean successful) is sometimes not called. The method Journal.close is called, but when the journal implementation uses a reentrant lock it can't unlock because close is called from a different thread.
> The reason for not calling doUnlock is that ClusterNode.stop() sets the status to "stopped", which causes all WorkspaceUpdateChannel methods to not work, including updateCommitted and updateCancelled. Therefore, it is possible that an operation is started but never completed nor cancelled.
> To solve the issue, I found that it is enough to let updateCommitted and updateCancelled to complete, so that operations that are in progress can finish.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira