spring-projects / spring-data-cassandra

Provides support to increase developer productivity in Java when using Apache Cassandra. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-cassandra/
Apache License 2.0
376 stars 309 forks source link

Batch operations not applied without errors #1333

Closed rbleuse closed 1 year ago

rbleuse commented 1 year ago

Hello,

we're using spring data cassandra 3.4.1, with a batch operation to write data in two tables, same keyspace

Sometimes the write result wasApplied is false but doesn't contain any error in executionInfo list with this code :

// insert batch to maintain consistency
cassandraTemplate.batchOps()
     .insert(post, postByClub)
     .execute()
     .doOnNext { writeResult ->
           writeResult.executionInfo.forEach { executionInfo ->
                 executionInfo.errors.forEach { error ->
                         log.error("Error encountered on node ${error.key}", error.value)
                 }
           }
      }
      .filter { writeResult -> writeResult.wasApplied() }
      .switchIfEmpty(
           run {
                 log.error("Batch operation was not applied for post $post")
                 Mono.error(Exception("xxx"))
           }
      )
      .map {
             xxxx
      }

The only log that is displayed is Batch operation was not applied for post YYYY How can we know what failed ?

mp911de commented 1 year ago

Do you happen to use lightweight-transactions? (IF NOT EXISTS, IF …)? If not, then this is a good question for the Datastax driver team/Cassandra server team.

rbleuse commented 1 year ago

No we're not using lightweight-transactions at all

mp911de commented 1 year ago

Thanks for your reply. I cannot help you with this one, I suggest reaching out to the Datastax driver team.