Permalink
Browse files

fix 2i updates with indentical values and timestamps

patch by Sam Tunnicliffe; reviewed by jbellis for CASSANDRA-5540
  • Loading branch information...
1 parent 6db71b2 commit 95cf9a5f0d5c437a9e042018eadc698e3fd5f9e0 @jbellis jbellis committed May 9, 2013
View
@@ -1,4 +1,5 @@
1.2.5
+ * fix 2i updates with indentical values and timestamps (CASSANDRA-5540)
* fix compaction throttling bursty-ness (CASSANDRA-4316)
* reduce memory consumption of IndexSummary (CASSANDRA-5506)
* remove per-row column name bloom filters (CASSANDRA-5492)
@@ -256,7 +256,7 @@ public void reduce(OnDiskAtom current)
container.addColumn(column);
if (indexer != SecondaryIndexManager.nullUpdater
&& !column.isMarkedForDelete()
- && container.getColumn(column.name()) != column)
+ && !container.getColumn(column.name()).equals(column))
{
indexer.remove(column);
}
@@ -141,7 +141,7 @@ public void reduce(IColumn column)
container.addColumn(column);
if (indexer != SecondaryIndexManager.nullUpdater
&& !column.isMarkedForDelete()
- && container.getColumn(column.name()) != column)
+ && !container.getColumn(column.name()).equals(column))
{
indexer.remove(column);
}
@@ -616,15 +616,20 @@ public void insert(IColumn column)
public void update(IColumn oldColumn, IColumn column)
{
+ if (oldColumn.equals(column))
+ return;
+
SecondaryIndex index = indexFor(column.name());
if (index == null)
return;
if (index instanceof PerColumnSecondaryIndex)
{
- ((PerColumnSecondaryIndex) index).delete(key.key, oldColumn);
+ // insert the new value before removing the old one, so we never have a period
+ // where the row is invisible to both queries (the opposite seems preferable); see CASSANDRA-5540
if (!column.isMarkedForDelete())
((PerColumnSecondaryIndex) index).insert(key.key, column);
+ ((PerColumnSecondaryIndex) index).delete(key.key, oldColumn);
}
}

0 comments on commit 95cf9a5

Please sign in to comment.