Don't include skipped values in read-repair
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9666e675 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9666e675 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9666e675 Branch: refs/heads/10657 Commit: 9666e675cad642e95e124b5009aa256af9cb4ff4 Parents: 1fc8696 Author: Sylvain Lebresne <sylv...@datastax.com> Authored: Tue Dec 22 17:30:30 2015 +0100 Committer: Sylvain Lebresne <sylv...@datastax.com> Committed: Wed Dec 23 12:08:06 2015 +0100 ---------------------------------------------------------------------- .../org/apache/cassandra/db/filter/ColumnFilter.java | 3 +-- .../org/apache/cassandra/service/DataResolver.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/9666e675/src/java/org/apache/cassandra/db/filter/ColumnFilter.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java b/src/java/org/apache/cassandra/db/filter/ColumnFilter.java index 9ad4b53..60cfad5 100644 --- a/src/java/org/apache/cassandra/db/filter/ColumnFilter.java +++ b/src/java/org/apache/cassandra/db/filter/ColumnFilter.java @@ -132,8 +132,7 @@ public class ColumnFilter */ public boolean canSkipValue(ColumnDefinition column) { - // We don't use that currently, see #10655 for more details. - return false; + return isFetchAll && selection != null && !selection.contains(column); } /** http://git-wip-us.apache.org/repos/asf/cassandra/blob/9666e675/src/java/org/apache/cassandra/service/DataResolver.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/DataResolver.java b/src/java/org/apache/cassandra/service/DataResolver.java index f3858d7..fc936f2 100644 --- a/src/java/org/apache/cassandra/service/DataResolver.java +++ b/src/java/org/apache/cassandra/service/DataResolver.java @@ -28,6 +28,7 @@ import org.apache.cassandra.config.ColumnDefinition; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.db.*; import org.apache.cassandra.db.filter.ClusteringIndexFilter; +import org.apache.cassandra.db.filter.ColumnFilter; import org.apache.cassandra.db.filter.DataLimits; import org.apache.cassandra.db.partitions.*; import org.apache.cassandra.db.rows.*; @@ -197,10 +198,21 @@ public class DataResolver extends ResponseResolver public void onCell(int i, Clustering clustering, Cell merged, Cell original) { - if (merged != null && !merged.equals(original)) + if (merged != null && !merged.equals(original) && !shouldSkip(merged)) currentRow(i, clustering).addCell(merged); } + private boolean shouldSkip(Cell cell) + { + // When we read, we may have some cell for which we've skipped the value for efficiency sakes. In that case, we + // should include them in read-repair as they don't have their proper value (see CASSANDRA-10655). This is ok though, + // those column are not actually requested by the user and are only present for the sake of CQL semantic (making sure + // we can always distinguish between a row that doesn't exist from one that do exist but has no value for the column + // requested by the user) and so it won't be unexpected by the user that those columns are not repaired. + ColumnDefinition column = cell.column(); + ColumnFilter filter = command.columnFilter(); + return column.isComplex() ? filter.canSkipValue(column, cell.path()) : filter.canSkipValue(column); + } }; }