Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The data got inserted into user table and got updated as above batch execution

...

.
The WriteTimeoutException.getWriteType() == BATCH, ensures data is inserted into the table

Approach

To handle above WriteTimeoutException we can use BatchStatement.Type

Code Block
BatchStatement batchStatement = new BatchStatement(BatchStatement.Type.UNLOGGEDLOGGED);

Below are the two batch types we executed for partial writes

  1. LOGGED

  2. UNLOGGED

  • LOGGED and UNLOGGED batch types, inserts data and throws exception on acknowledgement error. This needs to be handled in the code.

  • In cassandra docs, it is suggested to go with UNLOGGED batch type for better performance.

For detailed analysis, please refer hereBatch type of LOGGED, guarantees atomic insertion of data, and WriteTimeoutException.getWriteType() == BATCH, eventually written to the appropriate replicas and the developer doesn't have to do anything.

Thus, the above two checks handles partial write.