Recommended way to use Tephra transaction in coprocessors

8 views
Skip to first unread message

Mohammad Adnan Raza

unread,
Apr 13, 2016, 10:35:04 AM4/13/16
to Tephra User
Hello everyone,

I have requirement to use transaction in my hbase project. My requirement is - a client starts transaction and do some put operation. I'll have a coprocessor that will do few more puts. Now what I want is all these operation should go in single transaction. Meaning if client rollbacks her transaction my puts in coprocessor should also get rolledback.
My question is . is it possible to use transaction started in client in coprocessors? 


Poorna Chandra

unread,
Apr 13, 2016, 6:43:58 PM4/13/16
to Mohammad Adnan Raza, Tephra User
Hi Mohammad,

If your co-processor executes before Tephra's co-processor then it can execute data operations using the client transaction.

If your co-processor updates the same row as the client Put, then just modify the client Put as required. Tephra co-processor will then execute the modified Put within the client transaction.

If you are adding new Puts then you'll need to copy the transaction attributes [1] from the client Put to your put. Tephra encodes the transaction as an attribute of the operation. Copying over the attributes will make the new Put also a part of the client transaction. 

On a rollback (rollback results in a Delete operation with "cask.tx.rollback" attribute),  you'll have to generate a corresponding Delete operation for your Puts.

You can do the same thing for Gets, Scans and Deletes too.

Apache Phoenix does something similar with Apache Phoenix and Tephra co-processors.

Thanks,
Poorna.

1 - Transaction attributes are cask.tx and cask.tx.rollback.


--
You received this message because you are subscribed to the Google Groups "Tephra User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tephra-user...@googlegroups.com.
To post to this group, send email to tephr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tephra-user/d18bd226-5131-4e67-a784-2913ff57ed1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Poorna Chandra

unread,
Apr 14, 2016, 6:39:19 PM4/14/16
to Mohammad Adnan Raza, Tephra User
Hi Mohammad,

One more thing I missed mentioning for the case where you add new Puts - you'll have to use write pointer of the client transaction as the timestamp of the new Puts your co-processor creates. Tephra encodes client transaction as an attribute of operation called "cask.tx". TransactionCodec class can be used to decode the encoded transaction. 

Let me know if you have any questions.

Thanks,
Poorna.

Mohammad Adnan Raza

unread,
Apr 15, 2016, 1:05:54 AM4/15/16
to Poorna Chandra, Tephra User
That's great help.
Thank you Poorna for prompt response. I'll try this and if I stuck somewhere I'll come come again :)
--

With Best Regards,

       Mohd Adnan

       Feature Development Lead

       Mobile               +91-7498194516 
       Blog                   adnanfaizan.blogspot.in

Reply all
Reply to author
Forward
0 new messages