Handle possbile timeout when getting a read version. Updated documentation of the status json format

This commit is contained in:
Xin Dong 2020-09-23 13:50:59 -07:00
parent 50f681cd32
commit 77048c3d0f
2 changed files with 9 additions and 4 deletions

View File

@ -446,6 +446,8 @@
}
],
"recovery_state":{
"time_since_last_recovered":1,
"number_of_old_generations_of_tlogs":1,
"required_resolvers":1,
"required_proxies":1,
"required_grv_proxies":1,

View File

@ -1031,7 +1031,8 @@ ACTOR static Future<JsonBuilderObject> recoveryStateStatusFetcher(Database cx, W
state Future<TraceEventFields> mdActiveGensF = timeoutError(mWorker.interf.eventLogRequest.getReply( EventLogRequest( LiteralStringRef("MasterRecoveryGenerations") ) ), 1.0);
state Future<TraceEventFields> mdF = timeoutError(mWorker.interf.eventLogRequest.getReply( EventLogRequest( LiteralStringRef("MasterRecoveryState") ) ), 1.0);
state Future<TraceEventFields> mDBAvailableF = timeoutError(mWorker.interf.eventLogRequest.getReply( EventLogRequest( LiteralStringRef("MasterRecoveryAvailable") ) ), 1.0);
state Future<Version> rvF = timeoutError(tr.getReadVersion(), 1.0);
tr.setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE);
state Future<ErrorOr<Version>> rvF = errorOr(timeoutError(tr.getReadVersion(), 1.0));
wait(success(mdActiveGensF) && success(mdF) && success(rvF) && success(mDBAvailableF));
@ -1043,13 +1044,15 @@ ACTOR static Future<JsonBuilderObject> recoveryStateStatusFetcher(Database cx, W
message = JsonString::makeMessage(RecoveryStatus::names[mStatusCode], RecoveryStatus::descriptions[mStatusCode]);
*statusCode = mStatusCode;
Version rv = rvF.get();
ErrorOr<Version> rv = rvF.get();
const TraceEventFields& dbAvailableMsg = mDBAvailableF.get();
if (dbAvailableMsg.size() > 0) {
int64_t availableAtVersion = dbAvailableMsg.getInt64("AvailableAtVersion");
int numOfOldGensOfLogs = dbAvailableMsg.getInt("NumOfOldGensOfLogs");
double lastRecoveredSecondsAgo = std::max((int64_t)0, (int64_t)(rv - availableAtVersion)) / (double)SERVER_KNOBS->VERSIONS_PER_SECOND;
message["time_since_last_recovered"] = lastRecoveredSecondsAgo;
if (!rv.isError()) {
double lastRecoveredSecondsAgo = std::max((int64_t)0, (int64_t)(rv.get() - availableAtVersion)) / (double)SERVER_KNOBS->VERSIONS_PER_SECOND;
message["time_since_last_recovered"] = lastRecoveredSecondsAgo;
}
message["number_of_old_generations_of_tlogs"] = numOfOldGensOfLogs;
} else {
message["time_since_last_db_turned_available_seconds"] = -1;