Use backup_logging_enabled flag

The default is to enable new backup workers. Users can disable this flag to
turn off the backup worker feature.
This commit is contained in:
Jingyu Zhou 2020-02-03 19:51:02 -08:00
parent 7662b8e47f
commit 0db03f1d3c
11 changed files with 14 additions and 85 deletions

View File

@ -557,7 +557,7 @@
"auto_proxies":3,
"auto_resolvers":1,
"auto_logs":3,
"backup_type":2,
"backup_logging_enabled":1,
"proxies":5 // this field will be absent if a value has not been explicitly set
},
"data":{

View File

@ -41,7 +41,7 @@ void DatabaseConfiguration::resetInternal() {
tLogPolicy = storagePolicy = remoteTLogPolicy = Reference<IReplicationPolicy>();
remoteDesiredTLogCount = -1;
remoteTLogReplicationFactor = repopulateRegionAntiQuorum = 0;
backupType = BackupType::DEFAULT;
backupLoggingEnabled = true;
}
void parse( int* i, ValueRef const& v ) {
@ -184,8 +184,6 @@ bool DatabaseConfiguration::isValid() const {
tLogPolicy &&
getDesiredRemoteLogs() >= 1 &&
remoteTLogReplicationFactor >= 0 &&
backupType >= BackupType::DEFAULT &&
backupType < BackupType::END &&
repopulateRegionAntiQuorum >= 0 &&
repopulateRegionAntiQuorum <= 1 &&
usableRegions >= 1 &&
@ -326,9 +324,7 @@ StatusObject DatabaseConfiguration::toJSON(bool noPolicies) const {
result["auto_logs"] = autoDesiredTLogCount;
}
if (backupType > BackupType::DEFAULT) {
result["backup_type"] = (int)backupType;
}
result["backup_logging_enabled"] = (int32_t)backupLoggingEnabled;
}
return result;
@ -441,7 +437,7 @@ bool DatabaseConfiguration::setInternal(KeyRef key, ValueRef value) {
else if (ck == LiteralStringRef("remote_logs")) parse(&remoteDesiredTLogCount, value);
else if (ck == LiteralStringRef("remote_log_replicas")) parse(&remoteTLogReplicationFactor, value);
else if (ck == LiteralStringRef("remote_log_policy")) parseReplicationPolicy(&remoteTLogPolicy, value);
else if (ck == LiteralStringRef("backup_type")) { parse((&type), value); backupType = (BackupType::MutationLogType)type; }
else if (ck == LiteralStringRef("backup_logging_enabled")) { parse((&type), value); backupLoggingEnabled = (type != 0); }
else if (ck == LiteralStringRef("usable_regions")) parse(&usableRegions, value);
else if (ck == LiteralStringRef("repopulate_anti_quorum")) parse(&repopulateRegionAntiQuorum, value);
else if (ck == LiteralStringRef("regions")) parse(&regions, value);

View File

@ -179,7 +179,7 @@ struct DatabaseConfiguration {
Reference<IReplicationPolicy> remoteTLogPolicy;
// Backup Workers
BackupType backupType;
bool backupLoggingEnabled;
//Data centers
int32_t usableRegions;

View File

@ -987,62 +987,4 @@ struct WorkerBackupStatus {
}
};
struct BackupType {
// These enumerated values are stored in the database configuration, so can NEVER be changed. Only add new ones just before END.
enum MutationLogType {
// Use backup mutations generated at Proxies (befor 7.0).
DEFAULT = 0,
// Use tagged mutations pulled from TLogs (7.0 and afterwards)
TAGGED = 1,
// Use both of the above two for backup transition from default mechanism
// to the tagged mutation logging.
DEFAULT_AND_TAGGED = 2,
END = 3,
};
BackupType() : type(DEFAULT) {}
BackupType(MutationLogType t) : type(t) {
if ((uint32_t)t >= END) {
this->type = DEFAULT;
}
}
operator MutationLogType() const { return MutationLogType(type); }
bool isBackupWorkerEnabled() const {
return type == TAGGED || type == DEFAULT_AND_TAGGED;
}
template <class Ar>
void serialize(Ar& ar) {
serializer(ar, type);
}
std::string toString() const {
switch (type) {
case DEFAULT:
return "default";
case TAGGED:
return "tagged";
case DEFAULT_AND_TAGGED:
return "default+tagged";
default:
ASSERT(false);
}
return "";
}
static ErrorOr<BackupType> FromStringRef(StringRef s) {
if (s == LiteralStringRef("0")) return DEFAULT;
if (s == LiteralStringRef("1")) return TAGGED;
if (s == LiteralStringRef("2")) return DEFAULT_AND_TAGGED;
return default_error_or();
}
uint32_t type;
};
#endif

View File

@ -2387,7 +2387,7 @@ namespace fileBackup {
// Check if backup worker is enabled
DatabaseConfiguration dbConfig = wait(getDatabaseConfiguration(cx));
if (!dbConfig.backupType.isBackupWorkerEnabled()) {
if (!dbConfig.backupLoggingEnabled) {
return Void();
}
@ -3843,8 +3843,6 @@ public:
state BackupConfig config(current.first);
state EBackupState status = wait(config.stateEnum().getD(tr, false, EBackupState::STATE_NEVERRAN));
// Call clearBackupStartID().
if (!FileBackupAgent::isRunnable(status)) {
throw backup_unneeded();
}

View File

@ -591,7 +591,7 @@ const KeyRef JSONSchemas::statusSchema = LiteralStringRef(R"statusSchema(
"auto_resolvers":1,
"auto_logs":3,
"proxies":5,
"backup_type":2
"backup_logging_enabled":1
},
"data":{
"least_operating_space_bytes_log_server":0,

View File

@ -780,7 +780,7 @@ public:
}
}
if (req.configuration.backupType.isBackupWorkerEnabled()) {
if (req.configuration.backupLoggingEnabled) {
const int nBackup = std::max<int>(
(req.configuration.desiredLogRouterCount > 0 ? req.configuration.desiredLogRouterCount : tlogs.size()),
req.maxOldLogRouters);
@ -916,7 +916,7 @@ public:
for(int i = 0; i < proxies.size(); i++)
result.proxies.push_back(proxies[i].interf);
if (req.configuration.backupType.isBackupWorkerEnabled()) {
if (req.configuration.backupLoggingEnabled) {
const int nBackup = std::max<int>(tlogs.size(), req.maxOldLogRouters);
auto backupWorkers = getWorkersForRoleInDatacenter(dcId, ProcessClass::Backup, nBackup,
req.configuration, id_used);

View File

@ -878,13 +878,12 @@ void SimulationConfig::generateNormalConfig(int minimumReplication, int minimumR
ASSERT(false); // Programmer forgot to adjust cases.
}
set_config("backup_logging_enabled:=1");
if (deterministicRandom()->random01() < 0.5) {
int logSpill = deterministicRandom()->randomInt( TLogSpillType::VALUE, TLogSpillType::END );
set_config(format("log_spill:=%d", logSpill));
int logVersion = deterministicRandom()->randomInt( TLogVersion::MIN_RECRUITABLE, TLogVersion::MAX_SUPPORTED+1 );
set_config(format("log_version:=%d", logVersion));
int backupType = deterministicRandom()->randomInt(BackupType::DEFAULT, BackupType::END);
set_config(format("backup_type:=%d", backupType));
} else {
if (deterministicRandom()->random01() < 0.7)
set_config(format("log_version:=%d", TLogVersion::MAX_SUPPORTED));

View File

@ -2144,11 +2144,11 @@ struct TagPartitionedLogSystem : ILogSystem, ReferenceCounted<TagPartitionedLogS
logSystem->addPseudoLocality(tagLocalityLogRouterMapped);
TraceEvent e("AddPseudoLocality", logSystem->getDebugID());
e.detail("Locality1", "LogRouterMapped");
if (configuration.backupType.isBackupWorkerEnabled()) {
if (configuration.backupLoggingEnabled) {
logSystem->addPseudoLocality(tagLocalityBackup);
e.detail("Locality2", "Backup");
}
} else if (configuration.backupType.isBackupWorkerEnabled()) {
} else if (configuration.backupLoggingEnabled) {
// Single region uses log router tag for backup workers.
logSystem->logRouterTags = recr.tLogs.size() * std::max<int>(1, configuration.desiredLogRouterCount / std::max<int>(1, recr.tLogs.size()));
logSystem->addPseudoLocality(tagLocalityBackup);

View File

@ -1525,7 +1525,7 @@ ACTOR Future<Void> masterCore( Reference<MasterData> self ) {
self->addActor.send( changeCoordinators(self) );
Database cx = openDBOnServer(self->dbInfo, TaskPriority::DefaultEndpoint, true, true);
self->addActor.send(configurationMonitor(self, cx));
if (self->configuration.backupType.isBackupWorkerEnabled()) {
if (self->configuration.backupLoggingEnabled) {
self->addActor.send(recruitBackupWorkers(self, cx));
}

View File

@ -34,7 +34,6 @@ static const char* logTypes[] = {
"log_version:=2", "log_version:=3", "log_version:=4"
};
static const char* redundancies[] = { "single", "double", "triple" };
static const char* backupTypes[] = { "backup_type:=0", "backup_type:=1", "backup_type:=2" };
std::string generateRegions() {
std::string result;
@ -272,7 +271,7 @@ struct ConfigureDatabaseWorkload : TestWorkload {
if(g_simulator.speedUpSimulation) {
return Void();
}
state int randomChoice = deterministicRandom()->randomInt(0, 8);
state int randomChoice = deterministicRandom()->randomInt(0, 7);
if( randomChoice == 0 ) {
wait( success(
runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr) -> Future<Optional<Value>>
@ -323,11 +322,6 @@ struct ConfigureDatabaseWorkload : TestWorkload {
else if ( randomChoice == 6 ) {
// Some configurations will be invalid, and that's fine.
wait(success( IssueConfigurationChange( cx, logTypes[deterministicRandom()->randomInt( 0, sizeof(logTypes)/sizeof(logTypes[0]))], false ) ));
}
else if (randomChoice == 7) {
wait(success(IssueConfigurationChange(
cx, backupTypes[deterministicRandom()->randomInt(0, sizeof(backupTypes) / sizeof(backupTypes[0]))],
false)));
} else {
ASSERT(false);
}