Session.execute BatchStatement always return true in resultset

83 views
Skip to first unread message

zhujia...@hotmail.com

unread,
Aug 2, 2017, 8:47:09 PM8/2/17
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi, all:

I have some batch statements executed by session.execute method like below:

ResultSet resultSet = session.execute(batch);

But the resultSet.wasApplied always returns true even the batch is not applied successfully in database. Is it a proper behavior? Is there any means to fetch the actual batch execution result without re-querying? 


Thanks~

Andrew Tolbert

unread,
Aug 2, 2017, 11:44:07 PM8/2/17
to DataStax Java Driver for Apache Cassandra User Mailing List
Hello,

Are you executing conditional updates in your batch (IF EXISTS, IF NOT EXISTS)?  If your batch did not include conditional updates, it will always return true as stated in the javadoc for wasApplied:

For consistency, this method always returns true for non-conditional queries (although there is no reason to call the method in that case). This is also the case for conditional DDL statements (CREATE KEYSPACE... IF NOT EXISTSCREATE TABLE... IF NOT EXISTS), for which Cassandra doesn't return an [applied] column.
Note that, for versions of Cassandra strictly lower than 2.0.9 and 2.1.0-rc2, a server-side bug (CASSANDRA-7337) causes this method to always return true for batches containing conditional queries.

Also note the mention of CASSANDRA-7337 above, what version of C* are you running?  Also what do the statements look like that you are executing?

Thanks,
Andy
Reply all
Reply to author
Forward
0 new messages