What is row level isolation on cassandra

2,139 views
1,912 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,139
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

What is row level isolation on cassandra

  1. 1. What is Row Level Isolation on Cassandra INTHEFOERST Co., Ltd. tomitakazutaka
  2. 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. 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. 4. Implementation Read is not changed. As long as I investigated .... Perhaps….
  5. 5. ImplementationWrite to CommitlogCommitlog is not changed for Isolation.As long as I investigated ....Perhaps….
  6. 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. 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. 8. Implementation1.1.1 org.apache.cassandra.db.Memtable.resolve() private void resolve(DecoratedKey key, ColumnFamily cf) { ~~~~ Omission ~~~~ previous.addAll(cf, allocator, localCopyFunction); }
  9. 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. 10. ImplementationWhat’s SnapTree ? SnapTree is a concurrent AVL tree with fast cloning. See) http://ppl.stanford.edu/papers/ppopp207-bronson.pdf
  11. 11. Conclusion Notice the Cassandra’s transaction about the range. Cassandras row level isolation is atomic by one query and by one node
  12. 12. Thank you !

×