You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/10/20 15:46:46 UTC
svn commit: r1186803 - in /cassandra/branches/cassandra-0.8: CHANGES.txt
src/java/org/apache/cassandra/db/Table.java
Author: jbellis
Date: Thu Oct 20 13:46:46 2011
New Revision: 1186803
URL: http://svn.apache.org/viewvc?rev=1186803&view=rev
Log:
avoid locking on update when no indexes are involved
patch by jbellis; reviewed by slebrense for CASSANDRA-3386
Modified:
cassandra/branches/cassandra-0.8/CHANGES.txt
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java
Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1186803&r1=1186802&r2=1186803&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Thu Oct 20 13:46:46 2011
@@ -25,6 +25,8 @@
(CASSANDRA-3292)
* correct dropped messages logging (CASSANDRA-3377)
* CLI `describe keyspace <ks>` to show "Row Cache Provider" (CASSANDRA-3384)
+ * avoid locking on update when no indexes are involved (CASSANDRA-3386)
+
0.8.7
* Kill server on wrapped OOME such as from FileChannel.map (CASSANDRA-3201)
Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java?rev=1186803&r1=1186802&r2=1186803&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java Thu Oct 20 13:46:46 2011
@@ -424,29 +424,34 @@ public class Table
}
}
+ // Sharding the lock is insufficient to avoid contention when there is a "hot" row, e.g., for
+ // hint writes when a node is down (keyed by target IP). So it is worth special-casing the
+ // no-index case to avoid the synchronization.
+ if (mutatedIndexedColumns == null)
+ {
+ Memtable fullMemtable = cfs.apply(key, cf);
+ if (fullMemtable != null)
+ memtablesToFlush = addFullMemtable(memtablesToFlush, fullMemtable);
+ continue;
+ }
+ // else mutatedIndexedColumns != null
synchronized (indexLockFor(mutation.key()))
{
ColumnFamily oldIndexedColumns = null;
- if (mutatedIndexedColumns != null)
- {
- // with the raw data CF, we can just apply every update in any order and let
- // read-time resolution throw out obsolete versions, thus avoiding read-before-write.
- // but for indexed data we need to make sure that we're not creating index entries
- // for obsolete writes.
- oldIndexedColumns = readCurrentIndexedColumns(key, cfs, mutatedIndexedColumns);
- logger.debug("Pre-mutation index row is {}", oldIndexedColumns);
- ignoreObsoleteMutations(cf, mutatedIndexedColumns, oldIndexedColumns);
- }
+ // with the raw data CF, we can just apply every update in any order and let
+ // read-time resolution throw out obsolete versions, thus avoiding read-before-write.
+ // but for indexed data we need to make sure that we're not creating index entries
+ // for obsolete writes.
+ oldIndexedColumns = readCurrentIndexedColumns(key, cfs, mutatedIndexedColumns);
+ logger.debug("Pre-mutation index row is {}", oldIndexedColumns);
+ ignoreObsoleteMutations(cf, mutatedIndexedColumns, oldIndexedColumns);
Memtable fullMemtable = cfs.apply(key, cf);
if (fullMemtable != null)
memtablesToFlush = addFullMemtable(memtablesToFlush, fullMemtable);
- if (mutatedIndexedColumns != null)
- {
- // ignore full index memtables -- we flush those when the "master" one is full
- applyIndexUpdates(mutation.key(), cf, cfs, mutatedIndexedColumns, oldIndexedColumns);
- }
+ // ignore full index memtables -- we flush those when the "master" one is full
+ applyIndexUpdates(mutation.key(), cf, cfs, mutatedIndexedColumns, oldIndexedColumns);
}
}
}