Merge pull request #9043 from sfc-gh-anoyes/anoyes/idempotency-status-json
Add .cluster.idempotency_ids to status json
This commit is contained in:
commit
d012a74fa8
|
@ -902,6 +902,13 @@
|
|||
"num_tenants" : 1, // on data cluster, local count; on management cluster, total metacluster count
|
||||
"num_tenant_groups" : 10,
|
||||
"tenant_group_capacity" : 20,
|
||||
},
|
||||
"idempotency_ids" : {
|
||||
"size_bytes" : 0, // An estimate of the current number of bytes used in the database to store idempotency ids.
|
||||
"expired_version" : 0, // The commit status of a transaction whose commit version could be <= expired_version can no longer be determined.
|
||||
"expired_age" : 0, // The age in seconds of expired_version.
|
||||
"oldest_id_version" : 0, // The version of the oldest idempotency id still stored in the database.
|
||||
"oldest_id_age" : 0 // The age in seconds of the oldest_id_version.
|
||||
}
|
||||
},
|
||||
"client":{
|
||||
|
|
|
@ -232,6 +232,43 @@ ACTOR static Future<Optional<Key>> getBoundary(Reference<ReadYourWritesTransacti
|
|||
return result.front().key;
|
||||
}
|
||||
|
||||
ACTOR Future<JsonBuilderObject> getIdmpKeyStatus(Database db) {
|
||||
state Reference<ReadYourWritesTransaction> tr = makeReference<ReadYourWritesTransaction>(db);
|
||||
state int64_t size;
|
||||
state IdempotencyIdsExpiredVersion expired;
|
||||
state KeyBackedObjectProperty<IdempotencyIdsExpiredVersion, _Unversioned> expiredKey(idempotencyIdsExpiredVersion,
|
||||
Unversioned());
|
||||
state int64_t oldestIdVersion = 0;
|
||||
state int64_t oldestIdTime = 0;
|
||||
loop {
|
||||
try {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::READ_LOCK_AWARE);
|
||||
|
||||
wait(store(size, tr->getEstimatedRangeSizeBytes(idempotencyIdKeys)) &&
|
||||
store(expired, expiredKey.getD(tr)) &&
|
||||
success(getBoundary(tr, idempotencyIdKeys, Oldest::True, &oldestIdVersion, &oldestIdTime)));
|
||||
JsonBuilderObject result;
|
||||
result["size_bytes"] = size;
|
||||
if (expired.expired != 0) {
|
||||
result["expired_version"] = expired.expired;
|
||||
}
|
||||
if (expired.expiredTime != 0) {
|
||||
result["expired_age"] = int64_t(now()) - expired.expiredTime;
|
||||
}
|
||||
if (oldestIdVersion != 0) {
|
||||
result["oldest_id_version"] = oldestIdVersion;
|
||||
}
|
||||
if (oldestIdTime != 0) {
|
||||
result["oldest_id_age"] = int64_t(now()) - oldestIdTime;
|
||||
}
|
||||
return result;
|
||||
} catch (Error& e) {
|
||||
wait(tr->onError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ACTOR Future<Void> cleanIdempotencyIds(Database db, double minAgeSeconds) {
|
||||
state int64_t idmpKeySize;
|
||||
state int64_t candidateDeleteSize;
|
||||
|
@ -315,8 +352,10 @@ ACTOR Future<Void> cleanIdempotencyIds(Database db, double minAgeSeconds) {
|
|||
if (!finalRange.empty()) {
|
||||
tr->addReadConflictRange(finalRange);
|
||||
tr->clear(finalRange);
|
||||
tr->set(idempotencyIdsExpiredVersion,
|
||||
ObjectWriter::toValue(IdempotencyIdsExpiredVersion{ candidateDeleteVersion }, Unversioned()));
|
||||
tr->set(
|
||||
idempotencyIdsExpiredVersion,
|
||||
ObjectWriter::toValue(IdempotencyIdsExpiredVersion{ candidateDeleteVersion, candidateDeleteTime },
|
||||
Unversioned()));
|
||||
TraceEvent("IdempotencyIdsCleanerAttempt")
|
||||
.detail("Range", finalRange.toString())
|
||||
.detail("IdmpKeySizeEstimate", idmpKeySize)
|
||||
|
@ -332,4 +371,4 @@ ACTOR Future<Void> cleanIdempotencyIds(Database db, double minAgeSeconds) {
|
|||
}
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -602,8 +602,6 @@ const KeyRef JSONSchemas::statusSchema = R"statusSchema(
|
|||
"description":"abc"
|
||||
}
|
||||
],
|
||||
)statusSchema"
|
||||
R"statusSchema(
|
||||
"recovery_state":{
|
||||
"seconds_since_last_recovered":1,
|
||||
"required_resolvers":1,
|
||||
|
@ -976,6 +974,13 @@ const KeyRef JSONSchemas::statusSchema = R"statusSchema(
|
|||
"num_tenants":0,
|
||||
"num_tenant_groups":10,
|
||||
"tenant_group_capacity":20
|
||||
},
|
||||
"idempotency_ids":{
|
||||
"size_bytes": 0,
|
||||
"expired_version": 0,
|
||||
"expired_age": 0,
|
||||
"oldest_id_version": 0,
|
||||
"oldest_id_age": 0
|
||||
}
|
||||
},
|
||||
"client":{
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fdbclient/FDBTypes.h"
|
||||
#include "fdbclient/JsonBuilder.h"
|
||||
#include "fdbclient/PImpl.h"
|
||||
#include "flow/Arena.h"
|
||||
#include "flow/IRandom.h"
|
||||
|
@ -46,10 +47,11 @@ struct IdempotencyIdsExpiredVersion {
|
|||
// Any version at or below expired might have had its idempotency id expired. Any version greater than `expired`
|
||||
// definitely has not had it's idempotency id expired.
|
||||
Version expired = 0;
|
||||
int64_t expiredTime = 0;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar) {
|
||||
serializer(ar, expired);
|
||||
serializer(ar, expired, expiredTime);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -187,6 +189,8 @@ KeyRangeRef makeIdempotencySingleKeyRange(Arena& arena, Version version, uint8_t
|
|||
|
||||
void decodeIdempotencyKey(KeyRef key, Version& commitVersion, uint8_t& highOrderBatchIndex);
|
||||
|
||||
ACTOR Future<JsonBuilderObject> getIdmpKeyStatus(Database db);
|
||||
|
||||
// Delete zero or more idempotency ids older than minAgeSeconds
|
||||
//
|
||||
// Normally idempotency ids are deleted as part of the normal commit process, so this only needs to clean ids that
|
||||
|
|
|
@ -3124,6 +3124,8 @@ ACTOR Future<StatusReply> clusterGetStatus(
|
|||
state JsonBuilderObject recoveryStateStatus = wait(
|
||||
recoveryStateStatusFetcher(cx, ccWorker, mWorker, workers.size(), &status_incomplete_reasons, &statusCode));
|
||||
|
||||
state JsonBuilderObject idmpKeyStatus = wait(getIdmpKeyStatus(cx));
|
||||
|
||||
// machine metrics
|
||||
state WorkerEvents mMetrics = workerEventsVec[0].present() ? workerEventsVec[0].get().first : WorkerEvents();
|
||||
// process metrics
|
||||
|
@ -3505,6 +3507,8 @@ ACTOR Future<StatusReply> clusterGetStatus(
|
|||
if (!recoveryStateStatus.empty())
|
||||
statusObj["recovery_state"] = recoveryStateStatus;
|
||||
|
||||
statusObj["idempotency_ids"] = idmpKeyStatus;
|
||||
|
||||
// cluster messages subsection;
|
||||
JsonBuilderArray clientIssuesArr = getClientIssuesAsMessages(clientStatus);
|
||||
if (clientIssuesArr.size() > 0) {
|
||||
|
|
Loading…
Reference in New Issue