What is row level isolation on cassandra

  • 1,406 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,406
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. What is Row Level Isolation on Cassandra INTHEFOERST Co., Ltd. tomitakazutaka
  • 2. What is meaning of Cassandra’s transaction? One query is one transaction ! In Cassandra, a transaction is provided atomicity guarantees in executed one query. Complex transactions isn’t supported. And it is only by one node.
  • 3. Ex)CQL) UPDATE CBench SET Tag1 = ‘data1’, Tag2=‘data2’ where KEY = ‘john smith’; AtomicHector API)cluster = HFactory.getOrCreateCluster("Intheforest Cluster",chc);keyspace = HFactory.createKeyspace("CassandraBenchmark", cluster);mutator = HFactory.createMutator(keyspace, StringSerializer.get());mutator.addInsertion("venezia-20120613004300-000", "CBench",HFactory.createStringColumn("Tag1", "data1")) .addInsertion("venezia-20120613004300-000", "CBench", HFactory.createStringColumn("Tag2", "data2")) Atomic .addInsertion("venezia-20120613004300-000", "CBench",HFactory.createStringColumn("Tag3", "data3"));mutator.execute();
  • 4. Implementation Read is not changed. As long as I investigated .... Perhaps….
  • 5. ImplementationWrite to CommitlogCommitlog is not changed for Isolation.As long as I investigated ....Perhaps….
  • 6. ImplementationWriting process to MemTableorg.apache.cassandra.db.RowMutation.apply() ↓ org.apache.cassandra.db.Table.apply() ↓org.apache.cassandra.db.ColumnFamilyStore.apply() ↓ org.apache.cassandra.db. Memtable.put() ↓ org.apache.cassandra.db. Memtable. resolve()
  • 7. Implementation1.0.10 org.apache.cassandra.db. Memtable. resolve() private void resolve(DecoratedKey key, ColumnFamily cf) { ~~~~ Omission ~~~~ clonedCf.delete(cf); for (IColumn column : cf.getSortedColumns()) clonedCf.addColumn(column.localCopy(cfs, allocator), allocator); } increment simply for every column.
  • 8. Implementation1.1.1 org.apache.cassandra.db.Memtable.resolve() private void resolve(DecoratedKey key, ColumnFamily cf) { ~~~~ Omission ~~~~ previous.addAll(cf, allocator, localCopyFunction); }
  • 9. Implementationorg.apache.cassandra.db.AbstractColumnContainer.addAll() org.apache.cassandra.db.AtomicSortedColumns.addAll() public void addAll(ISortedColumns cm, Allocator allocator, Function<IColumn, IColumn> transformation) { Holder current, modified; main_loop: do { current = ref.get(); DeletionInfo newDelInfo = current.deletionInfo; if (newDelInfo.markedForDeleteAt < cm.getDeletionInfo().markedForDeleteAt) newDelInfo = cm.getDeletionInfo(); modified = new Holder(current.map.clone(), newDelInfo); SnapTree for (IColumn column : cm.getSortedColumns()) { (copy-on-write clone facilities) modified.addColumn(transformation.apply(column), allocator); // bail early if we know weve been beaten if (ref.get() != current) continue main_loop; CAS } } (See:http://en.wikipedia.org/wiki/Compare-and-swap) while (!ref.compareAndSet(current, modified)); }
  • 10. ImplementationWhat’s SnapTree ? SnapTree is a concurrent AVL tree with fast cloning. See) http://ppl.stanford.edu/papers/ppopp207-bronson.pdf
  • 11. Conclusion Notice the Cassandra’s transaction about the range. Cassandras row level isolation is atomic by one query and by one node
  • 12. Thank you !