You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Andrew Purtell (Created) (JIRA)" <ji...@apache.org> on 2012/04/19 03:52:40 UTC

[jira] [Created] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

[Coprocessors] Observer notifications on exceptions
---------------------------------------------------

                 Key: HBASE-5827
                 URL: https://issues.apache.org/jira/browse/HBASE-5827
             Project: HBase
          Issue Type: Improvement
          Components: coprocessors
            Reporter: Andrew Purtell


Benjamin Busjaeger wrote on dev@:

{quote}
Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.

If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?

{code}
    // pre-get CP hook
    if (withCoprocessor && (coprocessorHost != null)) {
      if (coprocessorHost.preGet(get, results)) {
        return results;
      }
    }
+    try{
    ...
+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.failedGet(get, results);
+        }
+        rethrow t;
+    }

    // post-get CP hook
    if (withCoprocessor && (coprocessorHost != null)) {
      coprocessorHost.postGet(get, results);
    }
{code}
{quote}


--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "stack (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13257244#comment-13257244 ] 

stack commented on HBASE-5827:
------------------------------

This seems like something we need if cps are to be able to keep a running context.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401758#comment-13401758 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

bq. Assume the PUT(and related things) that i created in preBatchPut is also needed while i use the preWALWrite, is there any way i can carry it in one flow?

You can package the WAL observer and the region observer in the same JAR and they can use any way you'd like to pass state between, perhaps by way of a singleton. Does this work? 
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13403252#comment-13403252 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

I'm going to let this issue stew for a few days and circle back next week to implement.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] [Comment Edited] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401837#comment-13401837 ] 

Andrew Purtell edited comment on HBASE-5827 at 6/27/12 12:36 AM:
-----------------------------------------------------------------

bq. Maybe some sort of tiered thing where the default calls the original

Yes.

So if the CP overrides this, it's done there.

If not, the base Observer class that CPs are supposed to be extending will call the original. 

Edit: And the aim is source level compatibility only.
                
      was (Author: apurtell):
    bq. Maybe some sort of tiered thing where the default calls the original

Yes.

So if the CP overrides this, it's done there.

If not, the base Observer class that CPs are supposed to be extending will call the original. 
                  
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Jesse Yates (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401834#comment-13401834 ] 

Jesse Yates commented on HBASE-5827:
------------------------------------

@Andrew - yup, that sounds fine. Are you thinking reflection to check existence of the right method or just calling both? Maybe some sort of tiered thing where the default calls the original?
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401788#comment-13401788 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

bq. This seems a bit wonky and could will probably break a lot of existing CP functionality (or at least be incredibly wasteful, generating the same puts again, etc). 

Maybe I don't follow.

Consider again:

{noformat}
+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.postGet(context, t, get, results);
+        }
+        rethrow t;
+    }
{noformat}


and then in psuedocode:

{noformat}
postGet(context, t, get, results):
    context.setThrowable(t)
    postGet(context, get, results)
{noformat}

So actually this would not break any existing CPs at all, it's the backwards compatible option.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13403244#comment-13403244 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

@Jon, both suggestions good, +1 and +1.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Jesse Yates (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401801#comment-13401801 ] 

Jesse Yates commented on HBASE-5827:
------------------------------------

The alternative might we something like:

{noformat}
Set<ErrorHandler> CPerrorHandlers = …
…
loadCPs(){
for(cp : loadedCPs){
  CPerrorHandlers.add( cp.getErrorHandler());
}
…
{noformat}

Conceptually, the success/failure handlers could be bound via a Callback<success, failure> on the actual operation. The success handler would just be the regular Observer (though maybe it might be worth looking into abstracting that into another class that the Observer would return on request to be added to the Callback). The failure handler would deal with the exception and be preloaded with the rest of the context. 

Conceptually, this is really close to how the CP host works already, so maybe I'm just proposing just doing a class-name change  - you've definitely thought about this interface more that me :) Ideally, I would like to see the operation just wrapped in a single handler that keeps track of the success/failure observers, and calls them as necessary (without dealing with too much other state, e.g. host != null feels clunky all over the place).
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401825#comment-13401825 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

@Jesse, for the sake of clarity I'm reading your +1 as a +1 on: "a new postXXX method that accepts an additional Throwable parameter plus a deprecated postXXX with that Throwable in the context for compatibility", as that is what was proposed. Please indicate if otherwise.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401787#comment-13401787 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

bq. We should also consider another interface based on (or at least conceptually similar to) SU's async stuff, so you could register a callback if you are interested in the error

@Jesse, thanks for commenting. I agree.

For illustration, what the above discussion so far considers is something like:

{noformat}
    if (withCoprocessor && (coprocessorHost != null)) {
      if (coprocessorHost.preGet(context, get, results)) {
        return results;
      }
    }
+   try {

// Existing code with formatting unchanged

+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.postGet(context, t, get, results);
+        }
+        rethrow t;
+    }
    if (withCoprocessor && (coprocessorHost != null)) {
-     coprocessorHost.postGet(context, get, results);
+     coprocessorHost.postGet(context, null, get, results);
    }
{noformat}

What would the alternative look like?

                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Jesse Yates (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401774#comment-13401774 ] 

Jesse Yates commented on HBASE-5827:
------------------------------------

bq. provide backwards compatible postXXX methods that put the Throwable into the Context and provide a new Context method for getting the caught Throwable, or null if nothing was caught;

This seems a bit wonky and could will probably break a lot of existing CP functionality (or at least be incredibly wasteful, generating the same puts again, etc). 

bq. pass the caught Throwable to new postXXX methods as a new parameter,

This seems a good way to do the failXXX method and not make things too different.

We should also consider another interface based on (or at least conceptually similar to) SU's async stuff, so you could register a callback if you are interested in the error, but otherwise is handled by the standard mechanisms. Probably going to be a bit cleaner that doing all this wrapping and calling stuff on failure. Maybe a scope expansion here, but seemed a reasonable application. 
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] [Comment Edited] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401820#comment-13401820 ] 

Andrew Purtell edited comment on HBASE-5827 at 6/27/12 12:11 AM:
-----------------------------------------------------------------

bq. I'll have to take some time to see if a bigger redesign is warranted. 

In the abstract I'd be all for a "coprocessors v2" if the result is more elegant. We are still pre Singularity. (But that does imply a time horizon.) The current framework design is the familiar upcall model, akin to kernel extensions, or a VFS interface. It counts simplicity and familiarity as pluses. But it is by no means the last word I'd say.

bq. TL;DR +1 on an onXXXXFailure method + a deprecated postXXX with error in context for compatibility

Ack. And thanks.
                
      was (Author: apurtell):
    bq. I'll have to take some time to see if a bigger redesign is warranted. 

In the abstract I'd be all for a "coprocessors v2" if the result is more elegant. We are still pre Singularity. (But that does imply a time horizon.) The current framework design is the familiar upcall model, akin to kernel extensions, or a VFS interface. It counts simplicity and familiarity as pluses. But it is by no means the last word I'd say.

bq. TL;DR +1 on an onXXXXFailure method + a deprecated postXXX with error in context for compatibility

Ack.
                  
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401820#comment-13401820 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

bq. I'll have to take some time to see if a bigger redesign is warranted. 

In the abstract I'd be all for a "coprocessors v2" if the result is more elegant. We are still pre Singularity. (But that does imply a time horizon.) The current framework design is the familiar upcall model, akin to kernel extensions, or a VFS interface. It counts simplicity and familiarity as pluses. But it is by no means the last word I'd say.

bq. TL;DR +1 on an onXXXXFailure method + a deprecated postXXX with error in context for compatibility

Ack.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401837#comment-13401837 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

bq. Maybe some sort of tiered thing where the default calls the original

Yes.

So if the CP overrides this, it's done there.

If not, the base Observer class that CPs are supposed to be extending will call the original. 
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "ramkrishna.s.vasudevan (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13257227#comment-13257227 ] 

ramkrishna.s.vasudevan commented on HBASE-5827:
-----------------------------------------------

+1 on such a feature.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Jesse Yates (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401813#comment-13401813 ] 

Jesse Yates commented on HBASE-5827:
------------------------------------

bq.the postXXX hook is already what you are calling a success handler. 

Yup, just trying to formalize the concept a little bit.

bq. nvoking the failure handler from a catch clause would be like failXXX but with another name (and class), right?

Yeah, but I'd rather have that encapsulated away from the main code, so the calling methods would just be able to call

{noformat}
...
internalPutter.put(stuff)
...
{noformat}

But again, basically what you have already (clearly more thought through than I did in the last 30mins). I'll have to take some time to see if a bigger redesign is warranted. 

TL;DR +1 on an onXXXXFailure method + a deprecated postXXX with error in context for compatibility
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Jonathan Hsieh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13402842#comment-13402842 ] 

Jonathan Hsieh commented on HBASE-5827:
---------------------------------------

Minor clarification -- what happens if the postXXX method throws an exception?  What if you want the postXXX method to eat the exception (because it somehow handles it)?

Specifically instead of this:
{code}
// Existing code with formatting unchanged

+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.postGet(context, t, get, results);
+        }
+        rethrow t;
+    }
    if (withCoprocessor && (coprocessorHost != null)) {
-     coprocessorHost.postGet(context, get, results);
+     coprocessorHost.postGet(context, null, get, results);
    }
{code}

would it make more sense to do this?
{code}
// Existing code with formatting unchanged

+    } catch (Throwable t) {
+        // failed-get CP hook
+        if (withCoprocessor && (coprocessorHost != null)) {
+          coprocessorHost.postGet(context, t, get, results);  // coproc has option to rethrow which would percolate out, or eat the exn if it handled it.
+          return; 
+        }
+        rethrow t; // no coproc so just rethrow
+    }
    if (withCoprocessor && (coprocessorHost != null)) {
-     coprocessorHost.postGet(context, get, results);
+     coprocessorHost.postGet(context, null, get, results);  // normal success case; coproc can throw exn as well.
    }
{code}

I'd also suggest that the base observer class implementation would check if there was a non-null exn argument and rethrow; if there was no exn it would do nothing (or maybe just call the original version with no exn argument).
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] [Assigned] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

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

Andrew Purtell reassigned HBASE-5827:
-------------------------------------

    Assignee: Andrew Purtell
    
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Benjamin Busjaeger (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13257643#comment-13257643 ] 

Benjamin Busjaeger commented on HBASE-5827:
-------------------------------------------

It may make sense to also pass the Throwable to the Coprocessor in the 'failedXXX' methods to give it a chance to introspect the error.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Jesse Yates (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401793#comment-13401793 ] 

Jesse Yates commented on HBASE-5827:
------------------------------------

bq. So actually this would not break any existing CPs at all, it's the backwards compatible option.

Yeah, you're right. I mis-understood and thought it would be more along the lines of calling cp.put(...) where the context there also includes the exception (since you probably care about the original put that borked things). This is better.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] [Comment Edited] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401764#comment-13401764 ] 

Andrew Purtell edited comment on HBASE-5827 at 6/26/12 11:07 PM:
-----------------------------------------------------------------

I'd like to revisit the API changes under consideration here. 

Do we want a new failXXX for every operation, or should we alter the postXXX methods? 

If the latter, then do we:

provide backwards compatible postXXX methods that put the Throwable into the Context and provide a new Context method for getting the caught Throwable, or null if nothing was caught;

or pass the caught Throwable to new postXXX methods as a new parameter, still provide backwards compatible postXXX methods that put the Throwable into the Context, but also deprecate the backwards compatible postXXX methods.

Edit: To clarify a bit, with the alternatives above involving postXXX, we would move code between preXXX and postXXX hooks into a try block, and in the catch handler call postXXX. The choice presented is basically between introducing a new failXXX method for every hook point or extending postXXX semantics to cover the exception path.
                
      was (Author: apurtell):
    I'd like to revisit the API changes under consideration here. 

Do we want a new failXXX for every operation, or should we alter the postXXX methods? 

If the latter, then do we:

provide backwards compatible postXXX methods that put the Throwable into the Context and provide a new Context method for getting the caught Throwable, or null if nothing was caught;

or pass the caught Throwable to new postXXX methods as a new parameter, still provide backwards compatible postXXX methods that put the Throwable into the Context, but also deprecate the backwards compatible postXXX methods.
                  
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401808#comment-13401808 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

The postXXX hook is already what you are calling a success handler. 

We would still need to get into position to catch the failure. Invoking the failure handler from a catch clause would be like failXXX but with another name (and class), right?

                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401811#comment-13401811 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

I don't want to hijack this discussion but when you say:
{quote}
Conceptually, the success/failure handlers could be bound via a Callback<success, failure> on the actual operation.
{quote}

this brings me back to an early thought I had about Coprocessors: that there would be a number of onThis and onThat style callbacks and the callback code (lambdas) would be "submitted" in client side APIs, and shipped to the server to execute. No need to install server side extensions at all. But for a variety of reasons we went instead with a server side upcall model, and that's what we have now.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401764#comment-13401764 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

I'd like to revisit the API changes under consideration here. 

Do we want a new failXXX for every operation, or should we alter the postXXX methods? 

If the latter, then do we:

provide backwards compatible postXXX methods that put the Throwable into the Context and provide a new Context method for getting the caught Throwable, or null if nothing was caught;

or pass the caught Throwable to new postXXX methods as a new parameter, still provide backwards compatible postXXX methods that put the Throwable into the Context, but also deprecate the backwards compatible postXXX methods.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>            Assignee: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "ramkrishna.s.vasudevan (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13257667#comment-13257667 ] 

ramkrishna.s.vasudevan commented on HBASE-5827:
-----------------------------------------------

@Andy
I have some thing which is similar to this and sorry if am diverting the current JIRA title. 
Suppose i want some state variable or some common object to be used across one flow, for eg. take the case of PUT.
May be i have the current PUT with me and from which i form the new PUTs to be added thro coprocessor hooks to a new region.
Assume the PUT(and related things) that i created in preBatchPut is also needed while i use the preWALWrite, is there any way i can carry it in one flow?
Hope am not missing anything? If you feel this can be done may be we can file an Improvement JIRA.  Please provide your suggestions 
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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] (HBASE-5827) [Coprocessors] Observer notifications on exceptions

Posted by "Andrew Purtell (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-5827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13257483#comment-13257483 ] 

Andrew Purtell commented on HBASE-5827:
---------------------------------------

I can try wrapping the code between pre and post hooks with try/catch in a way that doesn't change indenting inbetween.
                
> [Coprocessors] Observer notifications on exceptions
> ---------------------------------------------------
>
>                 Key: HBASE-5827
>                 URL: https://issues.apache.org/jira/browse/HBASE-5827
>             Project: HBase
>          Issue Type: Improvement
>          Components: coprocessors
>            Reporter: Andrew Purtell
>
> Benjamin Busjaeger wrote on dev@:
> {quote}
> Is there a reason that RegionObservers are not notified when a get/put/delete fails? Suppose I maintain some (transient) state in my Coprocessor that is created during preGet and discarded during postGet. If the get fails, postGet is not invoked, so I cannot remove the state.
> If there is a good reason, is there any other way to achieve the same thing? If not, would  it be possible to add something the snippet below to the code base?
> {code}
>     // pre-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       if (coprocessorHost.preGet(get, results)) {
>         return results;
>       }
>     }
> +    try{
>     ...
> +    } catch (Throwable t) {
> +        // failed-get CP hook
> +        if (withCoprocessor && (coprocessorHost != null)) {
> +          coprocessorHost.failedGet(get, results);
> +        }
> +        rethrow t;
> +    }
>     // post-get CP hook
>     if (withCoprocessor && (coprocessorHost != null)) {
>       coprocessorHost.postGet(get, results);
>     }
> {code}
> {quote}

--
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