Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: fatal stats mismatch #51808

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions c-deps/libroach/include/libroach.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ typedef struct {
int64_t gc_bytes_age;
int64_t sys_bytes;
int64_t sys_count;
int64_t abort_span_bytes;
int64_t last_update_nanos;
} MVCCStatsResult;

Expand Down
1 change: 1 addition & 0 deletions c-deps/libroach/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const rocksdb::Slice kLocalMax("\x02", 1);
const rocksdb::Slice kLocalRangeIDPrefix("\x01\x69", 2);
const rocksdb::Slice kLocalRangeIDReplicatedInfix("\x72", 1);
const rocksdb::Slice kLocalRangeAppliedStateSuffix("\x72\x61\x73\x6b", 4);
const rocksdb::Slice kLocalAbortSpanSuffix("\x61\x62\x63\x2d", 4);
const rocksdb::Slice kMeta2KeyMax("\x03\xff\xff", 3);
const rocksdb::Slice kTenantPrefix("\xfe", 1);
const rocksdb::Slice kMinKey("", 0);
Expand Down
17 changes: 17 additions & 0 deletions c-deps/libroach/mvcc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ MVCCStatsResult MVCCComputeStatsInternal(::rocksdb::Iterator* const iter_rep, DB
if (isSys) {
stats.sys_bytes += total_bytes;
stats.sys_count++;
if (decoded_key.starts_with(kLocalRangeIDPrefix)) {
// RangeID-local key.
int64_t range_id = 0;
rocksdb::Slice infix, suffix, detail;
if (!DecodeRangeIDKey(decoded_key, &range_id, &infix, &suffix, &detail)) {
stats.status = FmtStatus("unable to decode rangeID key");
return stats;
}

if (infix.compare(kLocalRangeIDReplicatedInfix) == 0) {
// Replicated RangeID-local key.
if (suffix.compare(kLocalAbortSpanSuffix) == 0) {
// Abort span key.
stats.abort_span_bytes += total_bytes;
}
}
}
} else {
if (!meta.deleted()) {
stats.live_bytes += total_bytes;
Expand Down
44 changes: 35 additions & 9 deletions c-deps/libroach/protos/storage/enginepb/mvcc.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions c-deps/libroach/protos/storage/enginepb/mvcc.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.