1
votes

I would like to get some clarification on BatchStatement execution.

I have added many insert/update statements for different tables into a batch. When I execute the batch, I expect that, if any one query failed, all other inserts/updates should not be success. But it is not happening. I can see partial updates/inserts.

How can I achieve this ? [ if any one query failed, all updates/inserts of the batch should not happened. ]

How can I get/print exact problematic query which caused failure of batch execution ?

What is purpose of LOGGED batch statement ?

http://www.datastax.com/drivers/java/2.0/com/datastax/driver/core/BatchStatement.Type.html#LOGGED

What is purpose of enable tracing in BatchStatement ? How can I print trace to debug query issues ?

http://www.datastax.com/drivers/java/2.0/com/datastax/driver/core/Statement.html#enableTracing%28%29

My code looks like,

BatchStatement batch = new BatchStatement();
batch.add(ps1.bind(xxx));
batch.add(ps2.bind(xxx));
batch.add(ps3.bind(xxx));
session.execute(batch);

Thanks,

Ramesh

1

1 Answers

1
votes

Read my answer about how atomic batches work in Cassandra here:

Atomic Batches in Cassandra

The logged batch will enable atomic batch. It means they go to the same co-ordinator.

You can enable tracing post CAssandra 1.2 for any query and not just batches. Each query will have a UUID associated with it. You can use that UUID to fetch the trace log.

See example: http://www.datastax.com/doc-source/developer/java-driver/tracing_t.html