You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Shai Erera (JIRA)" <ji...@apache.org> on 2011/06/11 14:24:59 UTC

[jira] [Created] (LUCENE-3193) TwoPhaseCommit interface

TwoPhaseCommit interface
------------------------

                 Key: LUCENE-3193
                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
             Project: Lucene - Java
          Issue Type: New Feature
          Components: core/index
            Reporter: Shai Erera
            Assignee: Shai Erera
             Fix For: 3.3, 4.0


I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
* prepareCommit()
* commit()
* rollback()

The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.

In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.

Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.

We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.

Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-3193) TwoPhaseCommit interface

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

Michael McCandless commented on LUCENE-3193:
--------------------------------------------

bq. This is mentioned in IndexWriter.rollback(). I don't think we should mention IW in TPC javadocs?

Ahh, you're right.  Good!

bq. And TPCTool.execute has a NOTE about it, saying that for some TPC implementations, calling rollback() after commit() was successfully executed may be a no-op.

Ahh, I missed that -- super.

But: perhaps a different exception should be thrown if there is a problem in the commit() loop vs the prepareCommit() loop?  This way caller can differentiate this case?

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera commented on LUCENE-3193:
------------------------------------

This is basically ready for commit. I'd appreciate a review of the definitions plus TPCTool impl. I will give it a couple of days before I commit. We can always fix issues later.

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Resolved] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera resolved LUCENE-3193.
--------------------------------

    Resolution: Fixed

Committed revision 1135204 (trunk).
Committed revision 1135215 (3x).

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch, LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Updated] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera updated LUCENE-3193:
-------------------------------

    Attachment: LUCENE-3193.patch

Patch introduces:

* TwoPhaseCommit interface
* TPCTool (inner to TPC interface) for running a 2-phase commit algorithm
* TPCWrapper, for running TPCTool w/ commitData
* Modify IW to impl TPC
* Add CHANGES entry (under the 3.x section).

TPCWrapper is just a convenience class for passing a different commitData long w/ every TPC. If you have a better name, I'm open to suggestions (maybe CommitDataWrapper?)

Core tests pass.

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Issue Comment Edited] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera edited comment on LUCENE-3193 at 6/11/11 12:56 PM:
--------------------------------------------------------------

Patch introduces:

* TwoPhaseCommit interface + test
* TPCTool (inner to TPC interface) for running a 2-phase commit algorithm
* TPCWrapper, for running TPCTool w/ commitData
* Modify IW to impl TPC
* Add CHANGES entry (under the 3.x section).

TPCWrapper is just a convenience class for passing a different commitData along w/ every TPC. If you have a better name, I'm open to suggestions (maybe CommitDataWrapper?)

Core tests pass.

      was (Author: shaie):
    Patch introduces:

* TwoPhaseCommit interface
* TPCTool (inner to TPC interface) for running a 2-phase commit algorithm
* TPCWrapper, for running TPCTool w/ commitData
* Modify IW to impl TPC
* Add CHANGES entry (under the 3.x section).

TPCWrapper is just a convenience class for passing a different commitData long w/ every TPC. If you have a better name, I'm open to suggestions (maybe CommitDataWrapper?)

Core tests pass.
  
> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera updated LUCENE-3193:
-------------------------------

    Attachment: LUCENE-3193.patch

Patch addresses Mike's comments (thanks !). Additionally, I extracted TPCTool into its own class, which now encapsulates the new exceptions + wrapper. Marked it @experimental too.

I think this is ready for commit.

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch, LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (LUCENE-3193) TwoPhaseCommit interface

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

Michael McCandless commented on LUCENE-3193:
--------------------------------------------

Patch looks great!  It's a nice addition.

TwoPhaseCommitTool.execute should be @experimental?

This seems similar to LUCENE-3131 (XA transactions support).  I don't
really understand what it takes to be "XA capable", but I assume it
means building the right wrapper around IW's existing transactional
APIs (like this).

Shouldn't TwoPhaseCommit be @lucene.experimental instead (not
internal)?  Ie, the idea is an app can also impl this interface, and
then use execute to commit all resources.

Javadocs should maybe state that on rollback the writer will have been
closed?  (rollback closes the writer)

One possible issue: if exceptions are hit in .commit(), which ought to
be rare since prepareCommit does all the "hard work", we go and
.rollback() all resources, even those that had successfully .commit'd,
right?  But, in general, this is tricky for a resource to handle
(rolling back when commit had succeeded).  EG, IndexWriter won't do
this correctly -- rollback will be a no-op in this case since it rolls
back to the last successful commit.

This is actually correctable, but it requires some more work to
properly wrap the IndexWriter.


> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera commented on LUCENE-3193:
------------------------------------

bq. TwoPhaseCommitTool.execute should be @experimental?

Since it is an inner class of TPC, and it is marked @experimental, I thought it is implied. But I will add it there too for clarity.

bq. Shouldn't TwoPhaseCommit be @lucene.experimental instead

You're right. I'll fix !

bq. Javadocs should maybe state that on rollback the writer will have been closed?

This is mentioned in IndexWriter.rollback(). I don't think we should mention IW in TPC javadocs?

bq. One possible issue: if exceptions are hit in .commit()

You're right. And TPCTool.execute has a *NOTE* about it, saying that for some TPC implementations, calling rollback() after commit() was successfully executed may be a no-op. I put it on execute because I think it is more related to the tool than TPC.rollback() definition.

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (LUCENE-3193) TwoPhaseCommit interface

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

Michael McCandless commented on LUCENE-3193:
--------------------------------------------

Looks great Shai!

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch, LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (LUCENE-3193) TwoPhaseCommit interface

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

Shai Erera commented on LUCENE-3193:
------------------------------------

{quote}
But: perhaps a different exception should be thrown if there is a problem in the commit() loop vs the prepareCommit() loop? This way caller can differentiate this case?
{quote}

Good idea. So instead of throwing IOE, we'll throw (Prepare)CommitFailException which takes a Throwable 'cause' and TPC 'obj'. We can make the two sub-class IOE for convenience (in case someone does not want to differentiate the two, it's easier to handle both cases in one catch block).

I'll add these and upload a new patch by tomorrow.

> TwoPhaseCommit interface
> ------------------------
>
>                 Key: LUCENE-3193
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3193
>             Project: Lucene - Java
>          Issue Type: New Feature
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>             Fix For: 3.3, 4.0
>
>         Attachments: LUCENE-3193.patch
>
>
> I would like to propose a TwoPhaseCommit interface which declares the methods necessary to implement a 2-phase commit algorithm:
> * prepareCommit()
> * commit()
> * rollback()
> The prepare/commit ones have variants that take a (Map<String,String> commitData) following the ones we have in IndexWriter.
> In addition, a TwoPhaseCommitTool which implements a 2-phase commit amongst several TPCs.
> Having IndexWriter implement that interface will allow running the 2-phase commit algorithm on multiple IWs or IW + any other object that implements the interface.
> We should mark the interface @lucene.internal so as to not block ourselves in the future. This is pretty advanced stuff anyway.
> Will post a patch soon

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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