Address review comments

This commit is contained in:
Xin Dong 2020-04-02 11:04:58 -07:00
parent 5f710bde6a
commit eaae9397e5
2 changed files with 11 additions and 8 deletions

View File

@ -1003,9 +1003,6 @@ void printStatus(StatusObjectReader statusObj, StatusClient::StatusLevel level,
StatusArray regions;
if (statusObjConfig.has("regions")) {
if (!activePrimaryDC.present()) {
outputString += "\n WARNING: Unable to determine primary datacenter";
}
outputString += "\n Regions: ";
regions = statusObjConfig["regions"].get_array();
bool isPrimary = false;

View File

@ -2150,8 +2150,9 @@ ACTOR Future<JsonBuilderObject> lockedStatusFetcher(Reference<AsyncVar<CachedSer
return statusObj;
}
ACTOR Future<Optional<Value>> getActivePrimaryDC(Database cx) {
ACTOR Future<JsonBuilderObject> getActivePrimaryDC(Database cx, Optional<Value>* output, JsonBuilderArray* messages) {
state ReadYourWritesTransaction tr(cx);
state JsonBuilderObject dummyReturn;
state Future<Void> readTimeout = delay(5); // so that we won't loop forever
loop {
@ -2163,12 +2164,16 @@ ACTOR Future<Optional<Value>> getActivePrimaryDC(Database cx) {
tr.setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE);
Optional<Value> res = wait(timeoutError(tr.get(primaryDatacenterKey), 5));
if (!res.present()) {
TraceEvent(SevWarn, "PrimaryDCAbsent");
messages->push_back(
JsonString::makeMessage("primary_dc_missing", "Unable to determine primary datacenter"));
}
return res;
*output = std::move(res);
return dummyReturn;
} catch (Error& e) {
if (e.code() == error_code_timed_out) {
TraceEvent(SevWarn, "FetchPrimaryDCTimeout");
messages->push_back(
JsonString::makeMessage("fetch_primary_dc_timedout", "Fetching primary DC timed out."));
return dummyReturn;
} else {
wait(tr.onError(e));
}
@ -2354,12 +2359,14 @@ ACTOR Future<StatusReply> clusterGetStatus(
state Future<ErrorOr<vector<std::pair<MasterProxyInterface, EventMap>>>> proxyFuture = errorOr(getProxiesAndMetrics(db, address_workers));
state int minReplicasRemaining = -1;
state Optional<Value> primaryDCO;
std::vector<Future<JsonBuilderObject>> futures2;
futures2.push_back(dataStatusFetcher(ddWorker, configuration.get(), &minReplicasRemaining));
futures2.push_back(workloadStatusFetcher(db, workers, mWorker, rkWorker, &qos, &data_overlay, &status_incomplete_reasons, storageServerFuture));
futures2.push_back(layerStatusFetcher(cx, &messages, &status_incomplete_reasons));
futures2.push_back(lockedStatusFetcher(db, &messages, &status_incomplete_reasons));
futures2.push_back(clusterSummaryStatisticsFetcher(pMetrics, storageServerFuture, tLogFuture, &status_incomplete_reasons));
futures2.push_back(getActivePrimaryDC(cx, &primaryDCO, &messages));
state std::vector<JsonBuilderObject> workerStatuses = wait(getAll(futures2));
int oldLogFaultTolerance = 100;
@ -2377,7 +2384,6 @@ ACTOR Future<StatusReply> clusterGetStatus(
// configArr could be empty
if (!configObj.empty()) {
Optional<Value> primaryDCO = wait(getActivePrimaryDC(cx));
if (primaryDCO.present()) {
statusObj["active_primary_dc"] = primaryDCO.get();
}