You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2008/07/30 14:47:31 UTC

[jira] Created: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

IndexWriter.rollback can hang if a previous call hit an exception
-----------------------------------------------------------------

                 Key: LUCENE-1347
                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
             Project: Lucene - Java
          Issue Type: Bug
          Components: Index
    Affects Versions: 2.3.1, 2.3
            Reporter: Michael McCandless
            Assignee: Michael McCandless
            Priority: Minor
             Fix For: 2.3.2, 2.4


IW.rollback has logic to make sure only one thread actually gets to do
the rollback whenever multiple threads are calling it at the same
time, by setting the "boolean closing" to true in the thread that got
there first.

Other threads wait for that variable to become false again before
returning from abort.

But, we are not restoring closing to false in a try/finally in
rollback(), which means on hitting an exception in rollback, a
subsequent call to rollback() will hang forever.

close() has the same logic, but there is already a try/finally there
to restore closing to false on exception.

The fix is straightforward.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

Posted by "Yonik Seeley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12618356#action_12618356 ] 

Yonik Seeley commented on LUCENE-1347:
--------------------------------------

Looks good Mike!
Just one question.... it looks like there might be a race condition in rollbackInternal()
Thread A calls rollbackInternal calls closeInternal which executes the finally block, waking up thread B.
Thread B sets closing=true and then calls closeInternal or rollbackInternal... meanwhile thread A executes the finally block in rollbackInternal and sets closing=false (oops, it shouldn't do that if closeInternal already did it).

That breaks the invariant, and thread C could then set closing=true and call closeInternal or rollbackInternal concurrently with thread B.

Not sure if this would cause any real problems or not though.


> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>         Attachments: LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

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

Michael McCandless updated LUCENE-1347:
---------------------------------------

    Attachment: LUCENE-1347.patch

Attached patch.  I plan to commit in a day or so, and then backport to 2.3.x.

> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>         Attachments: LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12618392#action_12618392 ] 

Michael McCandless commented on LUCENE-1347:
--------------------------------------------

Super, I'll commit shortly -- thanks Yonik!

> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>         Attachments: LUCENE-1347.patch, LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Commented: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

Posted by "Yonik Seeley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12618390#action_12618390 ] 

Yonik Seeley commented on LUCENE-1347:
--------------------------------------

Yep... the success flag ensures that closing=false  is only done once.

> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>         Attachments: LUCENE-1347.patch, LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Resolved: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

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

Michael McCandless resolved LUCENE-1347.
----------------------------------------

    Resolution: Fixed

> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>         Attachments: LUCENE-1347.patch, LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

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

Michael McCandless updated LUCENE-1347:
---------------------------------------

    Attachment: LUCENE-1347.patch

Woops, you're right -- thanks for the review!  Two threads (B & C) could in fact enter closeInternal at the same time.

Inside rollbackInternal, if I move the closeInternal() call out of the try/finally that sets closing to false, I believe that should resolve this?  In other words, I would only revert closing to false on hitting an exception in all the logic rollbackInternal does before calling closeInternal.

OK new patch attached.

> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.2, 2.4
>
>         Attachments: LUCENE-1347.patch, LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


[jira] Updated: (LUCENE-1347) IndexWriter.rollback can hang if a previous call hit an exception

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

Michael McCandless updated LUCENE-1347:
---------------------------------------

    Fix Version/s:     (was: 2.3.2)
                   2.3.3

> IndexWriter.rollback can hang if a previous call hit an exception
> -----------------------------------------------------------------
>
>                 Key: LUCENE-1347
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1347
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.3, 2.3.1
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.3.3, 2.4
>
>         Attachments: LUCENE-1347.patch, LUCENE-1347.patch
>
>
> IW.rollback has logic to make sure only one thread actually gets to do
> the rollback whenever multiple threads are calling it at the same
> time, by setting the "boolean closing" to true in the thread that got
> there first.
> Other threads wait for that variable to become false again before
> returning from abort.
> But, we are not restoring closing to false in a try/finally in
> rollback(), which means on hitting an exception in rollback, a
> subsequent call to rollback() will hang forever.
> close() has the same logic, but there is already a try/finally there
> to restore closing to false on exception.
> The fix is straightforward.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org