Lightweight Transactions

DSE Version: 6.7





As we have learned, Apache Cassandratm does not do a read before a write, but sometimes we need Cassandra to do the read before we write - and we need it to be atomic. This is where Lightweight Transactions come in. In this unit we'll understand lightweight transactions and learn how to use them.

No write up.

Exercise: Lightweight Transactions

In this exercise, you will:

  • Understand why lightweight transactions are necessary

  • Use lightweight transactions on inserts and updates

Because Apache Cassandra™ does not do a read before a write, applications may have problems with race conditions. A solution to these race conditions is lightweight transactions (LWT), which force Cassandra to perform the read before the write. Let’s first review the race condition, which is a result of upserts. Then we will see how LWT prevents this race condition.


1) Return to DataStax Studio. If you still have your DataStax Studio tab open in your browser, switch over to that tab. Otherwise, in DataStax Apache Cassandratm as a Service (CaaS), go to the view of your database. Click on the ellipsis to reveal the dropdown menu and click on the Launch Developer Studio link:

2) Complete the steps in the Bootcamp Lightweight Transactions notebook. This is the third notebook you will work through (you already completed the Bootcamp Data Modeling notebook and the Bootcamp Upserts notebook). Click on the Bootcamp Lightweight Transactions notebook. Once you have opened the notebook, follow the steps to complete this exercise.


No FAQs.

Using lightweight transactions: use lightweight transactions to complete a read before a write as an atomic operation.

Comments are closed.