Configuration : Cassandra 2.1
(if it matters Datastax Java driver 3.0.0 - driver users list couldn't help)
Platform Unix.

I have two tables:

CREATE TABLE unmapped_doc_type (
application_id uuid,
doc_type_id text,
metadata text,
PRIMARY KEY (application_id, doc_type_id)
)
CREATE TABLE unmapped_doc_type_counter (
application_id uuid,
doc_type_id text,
occurrences counter,
PRIMARY KEY (application_id, doc_type_id)
)

Table unmapped_doc_type has metadata for doc_type and
unmapped_doc_type_counter one has the number of occurences this doc type
was requested.
When I delete record in unmapped_doc_type I have to delete the same (same
values of application_id, doc_type_id) in unmapped_doc_type_counter table.
I am building DELETE statements using QueryBuilder, wrapping them into
com.datastax.driver.core.querybuilder.Batch as new Batch(statements, true)
and calling session.execute(batch) with this batch.

Previously I did it in a logged batch without any issues but upgrading from
Cassandra 1.2.x to 2.1 brings the following Exception message:
"Error executing batch. Message: Cannot include a counter statement in a
logged batch"
Sample of statement that fails:
"
BEGIN BATCH
DELETE FROM unmapped_doc_type
WHERE doc_type_id='567cfa05-aa41-4d4d-b65d-42dfd198ef2b' AND
application_id=41367e0c-5d6f-4b2f-897b-e25d6a52ee0e;
DELETE FROM unmapped_doc_type_counter
WHERE doc_type_id='567cfa05-aa41-4d4d-b65d-42dfd198ef2b' AND
application_id=41367e0c-5d6f-4b2f-897b-e25d6a52ee0e;
APPLY BATCH;
".

Question:
It looks like exception thrown from this line:

if (isLogged() && statement.isCounter()) throw new
InvalidRequestException("Cannot include a counter statement in a logged
batch");
<https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java#L172>
Why does DELETE statement for the table containing counter field return
isCounter() == true?
Is it a bug or expected behavior?
Thank you,
Alexei.

Reply via email to