Skip to content

Commit

Permalink
Merge "read repair chance should be set to 0 for datetiered strategy"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Feb 24, 2017
2 parents ce138ae + cfb536f commit c1ee317
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/database/cassandra/cql/cql_if.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <base/string_util.h>
#include <io/event_manager.h>
#include <database/gendb_if.h>
#include <database/gendb_constants.h>
#include <database/cassandra/cql/cql_if.h>
#include <database/cassandra/cql/cql_if_impl.h>
#include <database/cassandra/cql/cql_lib_if.h>
Expand Down Expand Up @@ -414,6 +415,8 @@ static const char * kQCompactionStrategy(
"compaction = {'class': "
"'org.apache.cassandra.db.compaction.%s'}");
static const std::string kQGCGraceSeconds("gc_grace_seconds = 0");
static const std::string kQReadRepairChanceDTCS(
"read_repair_chance = 0.0");

//
// Cf2CassCreateTableIfNotExists
Expand Down Expand Up @@ -441,8 +444,21 @@ std::string StaticCf2CassCreateTableIfNotExists(const GenDb::NewCf &cf,
int n(snprintf(cbuf, sizeof(cbuf), kQCompactionStrategy,
compaction_strategy.c_str()));
assert(!(n < 0 || n >= (int)sizeof(cbuf)));
query << ") WITH " << std::string(cbuf) << " AND " <<
kQGCGraceSeconds;

// The compaction strategy DateTieredCompactionStrategy precludes
// using read repair, because of the way timestamps are checked for
// DTCS compaction.In this case, you must set read_repair_chance to
// zero. For other compaction strategies, read repair should be
// enabled with a read_repair_chance value of 0.2 being typical
if (compaction_strategy ==
GenDb::g_gendb_constants.DATE_TIERED_COMPACTION_STRATEGY) {
query << ") WITH " << std::string(cbuf) << " AND " <<
kQReadRepairChanceDTCS << " AND " << kQGCGraceSeconds;
} else {
query << ") WITH " << std::string(cbuf) << " AND " <<
kQGCGraceSeconds;
}

return query.str();
}

Expand Down Expand Up @@ -503,8 +519,20 @@ std::string DynamicCf2CassCreateTableIfNotExists(const GenDb::NewCf &cf,
int n(snprintf(cbuf, sizeof(cbuf), kQCompactionStrategy,
compaction_strategy.c_str()));
assert(!(n < 0 || n >= (int)sizeof(cbuf)));
query << ")) WITH " << std::string(cbuf) << " AND " <<
kQGCGraceSeconds;

// The compaction strategy DateTieredCompactionStrategy precludes
// using read repair, because of the way timestamps are checked for
// DTCS compaction.In this case, you must set read_repair_chance to
// zero. For other compaction strategies, read repair should be
// enabled with a read_repair_chance value of 0.2 being typical
if (compaction_strategy ==
GenDb::g_gendb_constants.DATE_TIERED_COMPACTION_STRATEGY) {
query << ")) WITH " << std::string(cbuf) << " AND " <<
kQReadRepairChanceDTCS << " AND " << kQGCGraceSeconds;
} else {
query << ")) WITH " << std::string(cbuf) << " AND " <<
kQGCGraceSeconds;
}
return query.str();
}

Expand Down
1 change: 1 addition & 0 deletions src/database/cassandra/cql/test/cql_if_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ TEST_F(CqlIfTest, DynamicCfCreateTable) {
"column8, column9, column10, column11, column12)) "
"WITH compaction = {'class': "
"'org.apache.cassandra.db.compaction.DateTieredCompactionStrategy'} "
"AND read_repair_chance = 0.0 "
"AND gc_grace_seconds = 0");
EXPECT_EQ(expected_qstring1, actual_qstring1);
}
Expand Down

0 comments on commit c1ee317

Please sign in to comment.