kundera icon indicating copy to clipboard operation
kundera copied to clipboard

can delete action rollback now ?(cassandra1.1.6)

Open zhouhero opened this issue 13 years ago • 14 comments

I find that delete action can not rollback now in the sample code .(by using cassandra) in kundera 2.3 , can delete action rollback?

zhouhero avatar Dec 21 '12 08:12 zhouhero

If you work within Transaction boundary and explicitly invoke rollback before "commit", it can be rolled back. Or if any runtime exception it will implicitly rollback( if transaction has been begun)

Have a look at: https://github.com/impetus-opensource/Kundera/wiki/Transaction-Management

For it's usage.

-Vivek

mevivs avatar Dec 21 '12 08:12 mevivs

thanks for your answer! but, i know that only cassandra 1.2 can surrport atomic. Please look at it: http://www.datastax.com/dev/blog/atomic-batches-in-cassandra-1-2

How kundera do it? kundera do the transaction only in the client's cache not by the cassandra db. is it right? so before commit, the table is not locked really by db?

zhouhero avatar Dec 21 '12 09:12 zhouhero

Cassandra does not supports transaction, so in case of sucessful commit in "commit log" will be persisted.

What kundera does, maintains an event log of such processes and if opted for transaction, will flush them down in one go. So if something fails after, it can be immediately rollback by Kundera. This is useful when you consider "poly glot" persistence.

Yes, Kundera do the transaction at client side as cassandra does not support it!(server side). Table is not locked till you explicitly commit!

For Atomic batches, kundera wraps it with "batch.size" property, if you enable it in your persistence.xml, have a look at: https://github.com/impetus-opensource/Kundera/wiki/Batch-insert-update

-Vivek

mevivs avatar Dec 21 '12 09:12 mevivs

i see now. by the way, when commit, is kundera use batch to save data to cassandra db now or in the future? i know that Atomic batches is ok in cassandra 1.2.

zhouhero avatar Dec 21 '12 10:12 zhouhero

If you define "batch.size" property, it will save data in atomic batches in cassandra.

-Vivek

mevivs avatar Dec 21 '12 10:12 mevivs

begin() ..update data ..insert data commit();

↑ when commit, kundera flush data by batch or atomic batch?

zhouhero avatar Dec 21 '12 10:12 zhouhero

Define:

<property name="kundera.batch.size" value="5000" />

in persistence.xml

This will enable batch operation within kundera.

Now, if want to run within transaction, then you need to:

begin() ..update data ..insert data commit();

-Vivek

mevivs avatar Dec 21 '12 10:12 mevivs

it means that i can only select one mode(transaction or batch) in my program?

zhouhero avatar Dec 21 '12 10:12 zhouhero

:) You can select both !

Consider a scenario where you are dealing with multiple data sources then atomicity can not be guaranteed by cassandra!, but using transaction within kundera, you can.

-Vivek

mevivs avatar Dec 21 '12 10:12 mevivs

i see, by the way , the batch size can be set in program? like, client.setBatchSize(),

zhouhero avatar Dec 21 '12 10:12 zhouhero

No. this is one time setting for each emf.

-Vivek

mevivs avatar Dec 21 '12 10:12 mevivs

i see,thank you very much. by the way , in No.247 row of fellow file, it says that delete can not rollback now, is it really?

https://github.com/impetus-opensource/Kundera/trunk/kundera-cassandra/src/test/java/com/impetus/client/crud/EntityTransactionTest.java

zhouhero avatar Dec 21 '12 11:12 zhouhero

This is because, Cassandra does not allow you to reuse delete row key(at that time)! Not sure if it is enabled now

-Vivek

mevivs avatar Dec 21 '12 11:12 mevivs

i see. thank you!!! let me close this issue!

zhouhero avatar Dec 21 '12 11:12 zhouhero