From 87c6e8db9be5ab80332cdc5df1e8ea8a0bd606d7 Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Thu, 17 Aug 2017 13:39:22 -0400 Subject: [PATCH] *: Add Used field to StoreCapacity to reduce disk accounting confusion Fixes #13548 --- .../cockroach/pkg/roachpb/metadata.pb.cc | 68 ++++++- .../cockroach/pkg/roachpb/metadata.pb.h | 38 +++- pkg/roachpb/metadata.go | 16 +- pkg/roachpb/metadata.pb.go | 166 +++++++++++------- pkg/roachpb/metadata.proto | 8 + pkg/server/status/recorder_test.go | 2 + pkg/storage/engine/rocksdb.go | 22 +-- pkg/storage/metrics.go | 5 + pkg/storage/store.go | 1 + pkg/ui/src/js/protos.d.ts | 14 ++ pkg/ui/src/js/protos.js | 68 +++++++ pkg/ui/src/redux/nodes.ts | 2 + pkg/ui/src/util/proto.ts | 5 + .../nodeGraphs/dashboards/overview.tsx | 9 +- .../nodeGraphs/dashboards/storage.tsx | 7 +- .../containers/nodeGraphs/summaryBar.tsx | 10 +- .../cluster/containers/nodeOverview/index.tsx | 3 + 17 files changed, 336 insertions(+), 108 deletions(-) diff --git a/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.cc b/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.cc index e10fa592b04c..8696ce0a4f1d 100644 --- a/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.cc +++ b/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.cc @@ -2312,6 +2312,7 @@ void Percentiles::set_p90(double value) { #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int StoreCapacity::kCapacityFieldNumber; const int StoreCapacity::kAvailableFieldNumber; +const int StoreCapacity::kUsedFieldNumber; const int StoreCapacity::kLogicalBytesFieldNumber; const int StoreCapacity::kRangeCountFieldNumber; const int StoreCapacity::kLeaseCountFieldNumber; @@ -2401,9 +2402,10 @@ void StoreCapacity::Clear() { } } if (_has_bits_[0 / 32] & 252u) { - ::memset(&capacity_, 0, reinterpret_cast(&logical_bytes_) - - reinterpret_cast(&capacity_) + sizeof(logical_bytes_)); + ::memset(&capacity_, 0, reinterpret_cast(&used_) - + reinterpret_cast(&capacity_) + sizeof(used_)); } + logical_bytes_ = GOOGLE_LONGLONG(0); _has_bits_.Clear(); _internal_metadata_.Clear(); } @@ -2511,6 +2513,19 @@ bool StoreCapacity::MergePartialFromCodedStream( break; } + case 8: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(64u)) { + set_has_used(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( + input, &used_))); + } else { + goto handle_unusual; + } + break; + } + case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(72u)) { @@ -2584,6 +2599,10 @@ void StoreCapacity::SerializeWithCachedSizes( } if (cached_has_bits & 0x00000080u) { + ::google::protobuf::internal::WireFormatLite::WriteInt64(8, this->used(), output); + } + + if (cached_has_bits & 0x00000100u) { ::google::protobuf::internal::WireFormatLite::WriteInt64(9, this->logical_bytes(), output); } @@ -2639,13 +2658,19 @@ size_t StoreCapacity::ByteSizeLong() const { total_size += 1 + 8; } - if (has_logical_bytes()) { + if (has_used()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( - this->logical_bytes()); + this->used()); } } + if (has_logical_bytes()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int64Size( + this->logical_bytes()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -2689,10 +2714,13 @@ void StoreCapacity::MergeFrom(const StoreCapacity& from) { writes_per_second_ = from.writes_per_second_; } if (cached_has_bits & 0x00000080u) { - logical_bytes_ = from.logical_bytes_; + used_ = from.used_; } _has_bits_[0] |= cached_has_bits; } + if (cached_has_bits & 0x00000100u) { + set_logical_bytes(from.logical_bytes()); + } } void StoreCapacity::CopyFrom(const StoreCapacity& from) { @@ -2718,6 +2746,7 @@ void StoreCapacity::InternalSwap(StoreCapacity* other) { std::swap(range_count_, other->range_count_); std::swap(lease_count_, other->lease_count_); std::swap(writes_per_second_, other->writes_per_second_); + std::swap(used_, other->used_); std::swap(logical_bytes_, other->logical_bytes_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -2777,15 +2806,38 @@ void StoreCapacity::set_available(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:cockroach.roachpb.StoreCapacity.available) } -bool StoreCapacity::has_logical_bytes() const { +bool StoreCapacity::has_used() const { return (_has_bits_[0] & 0x00000080u) != 0; } -void StoreCapacity::set_has_logical_bytes() { +void StoreCapacity::set_has_used() { _has_bits_[0] |= 0x00000080u; } -void StoreCapacity::clear_has_logical_bytes() { +void StoreCapacity::clear_has_used() { _has_bits_[0] &= ~0x00000080u; } +void StoreCapacity::clear_used() { + used_ = GOOGLE_LONGLONG(0); + clear_has_used(); +} +::google::protobuf::int64 StoreCapacity::used() const { + // @@protoc_insertion_point(field_get:cockroach.roachpb.StoreCapacity.used) + return used_; +} +void StoreCapacity::set_used(::google::protobuf::int64 value) { + set_has_used(); + used_ = value; + // @@protoc_insertion_point(field_set:cockroach.roachpb.StoreCapacity.used) +} + +bool StoreCapacity::has_logical_bytes() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +void StoreCapacity::set_has_logical_bytes() { + _has_bits_[0] |= 0x00000100u; +} +void StoreCapacity::clear_has_logical_bytes() { + _has_bits_[0] &= ~0x00000100u; +} void StoreCapacity::clear_logical_bytes() { logical_bytes_ = GOOGLE_LONGLONG(0); clear_has_logical_bytes(); diff --git a/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.h b/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.h index 365ac0927a65..1ecccae5bf58 100644 --- a/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.h +++ b/c-deps/libroach/protos/cockroach/pkg/roachpb/metadata.pb.h @@ -890,6 +890,12 @@ class StoreCapacity : public ::google::protobuf::MessageLite /* @@protoc_inserti double writes_per_second() const; void set_writes_per_second(double value); + bool has_used() const; + void clear_used(); + static const int kUsedFieldNumber = 8; + ::google::protobuf::int64 used() const; + void set_used(::google::protobuf::int64 value); + bool has_logical_bytes() const; void clear_logical_bytes(); static const int kLogicalBytesFieldNumber = 9; @@ -902,6 +908,8 @@ class StoreCapacity : public ::google::protobuf::MessageLite /* @@protoc_inserti void clear_has_capacity(); void set_has_available(); void clear_has_available(); + void set_has_used(); + void clear_has_used(); void set_has_logical_bytes(); void clear_has_logical_bytes(); void set_has_range_count(); @@ -925,6 +933,7 @@ class StoreCapacity : public ::google::protobuf::MessageLite /* @@protoc_inserti ::google::protobuf::int32 range_count_; ::google::protobuf::int32 lease_count_; double writes_per_second_; + ::google::protobuf::int64 used_; ::google::protobuf::int64 logical_bytes_; friend struct protobuf_cockroach_2fpkg_2froachpb_2fmetadata_2eproto::TableStruct; }; @@ -2248,15 +2257,38 @@ inline void StoreCapacity::set_available(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:cockroach.roachpb.StoreCapacity.available) } -inline bool StoreCapacity::has_logical_bytes() const { +inline bool StoreCapacity::has_used() const { return (_has_bits_[0] & 0x00000080u) != 0; } -inline void StoreCapacity::set_has_logical_bytes() { +inline void StoreCapacity::set_has_used() { _has_bits_[0] |= 0x00000080u; } -inline void StoreCapacity::clear_has_logical_bytes() { +inline void StoreCapacity::clear_has_used() { _has_bits_[0] &= ~0x00000080u; } +inline void StoreCapacity::clear_used() { + used_ = GOOGLE_LONGLONG(0); + clear_has_used(); +} +inline ::google::protobuf::int64 StoreCapacity::used() const { + // @@protoc_insertion_point(field_get:cockroach.roachpb.StoreCapacity.used) + return used_; +} +inline void StoreCapacity::set_used(::google::protobuf::int64 value) { + set_has_used(); + used_ = value; + // @@protoc_insertion_point(field_set:cockroach.roachpb.StoreCapacity.used) +} + +inline bool StoreCapacity::has_logical_bytes() const { + return (_has_bits_[0] & 0x00000100u) != 0; +} +inline void StoreCapacity::set_has_logical_bytes() { + _has_bits_[0] |= 0x00000100u; +} +inline void StoreCapacity::clear_has_logical_bytes() { + _has_bits_[0] &= ~0x00000100u; +} inline void StoreCapacity::clear_logical_bytes() { logical_bytes_ = GOOGLE_LONGLONG(0); clear_has_logical_bytes(); diff --git a/pkg/roachpb/metadata.go b/pkg/roachpb/metadata.go index c27276726b4b..5dc773aaf1f2 100644 --- a/pkg/roachpb/metadata.go +++ b/pkg/roachpb/metadata.go @@ -262,11 +262,11 @@ func (p Percentiles) String() string { // String returns a string representation of the StoreCapacity. func (sc StoreCapacity) String() string { - return fmt.Sprintf("disk (capacity=%s, available=%s, logicalBytes=%s), "+ + return fmt.Sprintf("disk (capacity=%s, available=%s, used=%s, logicalBytes=%s), "+ "ranges=%d, leases=%d, writes=%.2f, "+ "bytesPerReplica={%s}, writesPerReplica={%s}", humanizeutil.IBytes(sc.Capacity), humanizeutil.IBytes(sc.Available), - humanizeutil.IBytes(sc.LogicalBytes), + humanizeutil.IBytes(sc.Used), humanizeutil.IBytes(sc.LogicalBytes), sc.RangeCount, sc.LeaseCount, sc.WritesPerSecond, sc.BytesPerReplica, sc.WritesPerReplica) } @@ -276,7 +276,17 @@ func (sc StoreCapacity) FractionUsed() float64 { if sc.Capacity == 0 { return 0 } - return float64(sc.Capacity-sc.Available) / float64(sc.Capacity) + // Prefer computing the fraction of available disk space used by considering + // anything on the disk that isn't in the store's data directory just a sunk + // cost, not truly part of the disk's capacity. This means that the disk's + // capacity is really just the available space plus cockroach's usage. + // + // Fall back to a more pessimistic calcuation of disk usage if we don't know + // how much space the store's data is taking up. + if sc.Used == 0 { + return float64(sc.Capacity-sc.Available) / float64(sc.Capacity) + } + return float64(sc.Used) / float64(sc.Available+sc.Used) } // CombinedAttrs returns the full list of attributes for the store, including diff --git a/pkg/roachpb/metadata.pb.go b/pkg/roachpb/metadata.pb.go index 49d1039319c1..1fcf47551ba1 100644 --- a/pkg/roachpb/metadata.pb.go +++ b/pkg/roachpb/metadata.pb.go @@ -104,8 +104,16 @@ func (*Percentiles) Descriptor() ([]byte, []int) { return fileDescriptorMetadata // StoreCapacity contains capacity information for a storage device. type StoreCapacity struct { - Capacity int64 `protobuf:"varint,1,opt,name=capacity" json:"capacity"` + // Total capacity of the disk used by the store, including space used by the + // operating system and other applications. + Capacity int64 `protobuf:"varint,1,opt,name=capacity" json:"capacity"` + // Available space remaining on the disk used by the store. Available int64 `protobuf:"varint,2,opt,name=available" json:"available"` + // Amount of disk space used by the data in the CockroachDB store. Note that + // this is going to be less than (capacity - available), because those two + // fields consider the entire disk and everything on it, while this only + // tracks the store's disk usage. + Used int64 `protobuf:"varint,8,opt,name=used" json:"used"` // Amount of logical bytes stored in the store, ignoring RocksDB space // overhead. Useful for rebalancing so that moving a replica from one store // to another actually removes its bytes from the source store even though @@ -581,6 +589,9 @@ func (m *StoreCapacity) MarshalTo(dAtA []byte) (int, error) { return 0, err } i += n3 + dAtA[i] = 0x40 + i++ + i = encodeVarintMetadata(dAtA, i, uint64(m.Used)) dAtA[i] = 0x48 i++ i = encodeVarintMetadata(dAtA, i, uint64(m.LogicalBytes)) @@ -1005,6 +1016,7 @@ func (m *StoreCapacity) Size() (n int) { n += 1 + l + sovMetadata(uint64(l)) l = m.WritesPerReplica.Size() n += 1 + l + sovMetadata(uint64(l)) + n += 1 + sovMetadata(uint64(m.Used)) n += 1 + sovMetadata(uint64(m.LogicalBytes)) return n } @@ -1972,6 +1984,25 @@ func (m *StoreCapacity) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Used", wireType) + } + m.Used = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Used |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LogicalBytes", wireType) @@ -2883,70 +2914,71 @@ var ( func init() { proto.RegisterFile("cockroach/pkg/roachpb/metadata.proto", fileDescriptorMetadata) } var fileDescriptorMetadata = []byte{ - // 1040 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x6f, 0x1b, 0xc5, - 0x1b, 0xce, 0xfa, 0x23, 0xbb, 0x7e, 0x13, 0xff, 0xf2, 0xf3, 0x88, 0x0f, 0xcb, 0x08, 0xdb, 0x59, - 0xb5, 0x52, 0xf8, 0x90, 0xed, 0x1a, 0x59, 0x55, 0x82, 0x0a, 0xc4, 0x0d, 0x95, 0x4c, 0xa1, 0x8a, - 0x36, 0xa5, 0x07, 0x2e, 0xd6, 0x64, 0x77, 0x70, 0x97, 0x6c, 0x76, 0xad, 0xd9, 0xb1, 0x5b, 0xdf, - 0x91, 0x38, 0x54, 0x48, 0x1c, 0x39, 0xe6, 0xc2, 0x8d, 0x03, 0x47, 0xfe, 0x01, 0xa4, 0x88, 0x13, - 0x47, 0x4e, 0x11, 0x98, 0x0b, 0x67, 0x8e, 0x3d, 0xa1, 0x79, 0x77, 0x66, 0xbd, 0x4e, 0x5d, 0x89, - 0x14, 0x89, 0xdb, 0xf8, 0x7d, 0x9f, 0xe7, 0xdd, 0xf7, 0x6b, 0x9e, 0x31, 0x5c, 0x73, 0x23, 0xf7, - 0x84, 0x47, 0xd4, 0x7d, 0xd8, 0x1e, 0x9f, 0x8c, 0xda, 0x78, 0x1a, 0x1f, 0xb7, 0x4f, 0x99, 0xa0, - 0x1e, 0x15, 0xb4, 0x35, 0xe6, 0x91, 0x88, 0x48, 0x25, 0x45, 0xb5, 0x14, 0xa2, 0xb6, 0xb3, 0x4c, - 0x9c, 0x08, 0x3f, 0x68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f4, 0xe8, 0xc9, - 0x3b, 0x50, 0x14, 0x3e, 0x53, 0x7f, 0x39, 0x36, 0xba, 0xaf, 0xae, 0x88, 0x75, 0xdf, 0x67, 0xba, - 0x27, 0x09, 0x56, 0xdd, 0x92, 0x0f, 0xa0, 0x20, 0x5d, 0x52, 0xfa, 0xe4, 0x3b, 0x21, 0x6b, 0x28, - 0x69, 0xe9, 0x3b, 0x61, 0x33, 0x52, 0x83, 0xe2, 0x94, 0x06, 0x93, 0x44, 0xbc, 0xb4, 0x27, 0x31, - 0xa9, 0x08, 0xdf, 0x19, 0x60, 0xaa, 0x5d, 0x21, 0x6f, 0x42, 0xe9, 0x94, 0x7e, 0x11, 0xf1, 0xe1, - 0x94, 0x06, 0xaa, 0x1f, 0x65, 0xd5, 0x8f, 0xe2, 0x27, 0xd2, 0xe1, 0x58, 0xe8, 0x7f, 0x40, 0x03, - 0xc4, 0xfa, 0xa1, 0xc2, 0xe6, 0x2e, 0x61, 0xa5, 0xc3, 0xb1, 0xd0, 0x2f, 0xb1, 0x35, 0x28, 0x8e, - 0xa9, 0x70, 0x1f, 0x2e, 0x89, 0x63, 0x62, 0x92, 0x22, 0x3c, 0x09, 0x63, 0x81, 0x0a, 0x9b, 0x15, - 0xc5, 0xd4, 0x9a, 0xe4, 0xd9, 0xdf, 0x3e, 0xff, 0xbd, 0xbe, 0x76, 0x3e, 0xaf, 0x1b, 0xbf, 0xcc, - 0xeb, 0xc6, 0xaf, 0xf3, 0xba, 0xf1, 0xdb, 0xbc, 0x6e, 0x7c, 0xf3, 0x47, 0x7d, 0xed, 0x33, 0x53, - 0x35, 0xe9, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x74, 0x09, 0xb0, 0x07, 0x42, 0x0a, 0x00, 0x00, + // 1050 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0x1b, 0xc5, + 0x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0xbf, 0x13, 0x45, 0x64, 0xbf, 0xbe, + 0xa4, 0x2f, 0xf3, 0x57, 0x45, 0x91, 0x53, 0x06, 0xb9, 0x05, 0x76, 0x18, 0x7b, 0x34, 0x94, 0x7b, + 0x67, 0x22, 0xfb, 0xb5, 0x25, 0xec, 0x8f, 0x15, 0x44, 0x2f, 0xa5, 0xa6, 0x90, 0x3b, 0x50, 0x39, + 0x62, 0x7c, 0xc2, 0xf8, 0x03, 0xc6, 0x93, 0x20, 0x8e, 0x70, 0x3d, 0xd6, 0x3a, 0xf5, 0x25, 0x31, + 0x14, 0x42, 0x85, 0x58, 0xa4, 0x39, 0x5f, 0x16, 0x60, 0x03, 0x2f, 0xc4, 0xa2, 0xa2, 0x65, 0xba, + 0x6f, 0xfc, 0x73, 0xdd, 0xcf, 0x9a, 0x51, 0xb8, 0x72, 0x33, 0xde, 0x05, 0x53, 0x4e, 0x44, 0xb5, + 0x71, 0x6b, 0x09, 0x73, 0x71, 0xd6, 0x7a, 0x77, 0x24, 0x89, 0xf4, 0x72, 0x37, 0x38, 0xed, 0xe4, + 0xe6, 0x92, 0x00, 0x0b, 0xb7, 0xfe, 0xf2, 0x1d, 0x77, 0xbe, 0x36, 0xa0, 0xaa, 0xda, 0x40, 0x7d, + 0x57, 0x2b, 0xe2, 0x0b, 0x36, 0x62, 0x3f, 0x27, 0xc8, 0x05, 0x14, 0xe4, 0xe6, 0xf3, 0x05, 0x19, + 0x5f, 0xb5, 0xcb, 0x5a, 0xec, 0x7c, 0x08, 0xb6, 0x1e, 0x3d, 0x79, 0x07, 0x4a, 0x22, 0x60, 0xea, + 0xcf, 0xc8, 0x5a, 0xe7, 0xd5, 0x25, 0xb1, 0xee, 0x07, 0x4c, 0xf7, 0x24, 0xc5, 0xaa, 0x5b, 0xf2, + 0x01, 0x98, 0xd2, 0x25, 0x45, 0x51, 0xbe, 0x20, 0xb2, 0x86, 0xb2, 0x16, 0xc5, 0x13, 0x36, 0x25, + 0x75, 0x28, 0x4d, 0x68, 0x38, 0x4e, 0x65, 0x4d, 0x7b, 0x52, 0x93, 0x8a, 0xf0, 0x9d, 0x01, 0x96, + 0xda, 0x15, 0xf2, 0x26, 0x94, 0x4f, 0xe9, 0x17, 0x31, 0x1f, 0x4c, 0x68, 0xa8, 0xfa, 0x51, 0x51, + 0xfd, 0x28, 0x7d, 0x22, 0x1d, 0xae, 0x8d, 0xfe, 0x07, 0x34, 0x44, 0x6c, 0x10, 0x29, 0x6c, 0xe1, + 0x12, 0x56, 0x3a, 0x5c, 0x1b, 0xfd, 0x12, 0x5b, 0x87, 0xd2, 0x88, 0x0a, 0xef, 0xe1, 0x82, 0x6c, + 0xa6, 0x26, 0x29, 0xcf, 0xe3, 0x28, 0x11, 0xa8, 0xbd, 0x79, 0xb9, 0xcc, 0xac, 0x69, 0x9e, 0xbd, + 0xad, 0xf3, 0xdf, 0x1b, 0x2b, 0xe7, 0xb3, 0x86, 0xf1, 0xcb, 0xac, 0x61, 0xfc, 0x3a, 0x6b, 0x18, + 0xbf, 0xcd, 0x1a, 0xc6, 0x37, 0x7f, 0x34, 0x56, 0x3e, 0xb3, 0x54, 0x93, 0xfe, 0x0e, 0x00, 0x00, + 0xff, 0xff, 0x27, 0xc0, 0xd3, 0x68, 0x5c, 0x0a, 0x00, 0x00, } diff --git a/pkg/roachpb/metadata.proto b/pkg/roachpb/metadata.proto index 614f86af3a83..6f029c7b1d27 100644 --- a/pkg/roachpb/metadata.proto +++ b/pkg/roachpb/metadata.proto @@ -106,8 +106,16 @@ message Percentiles { message StoreCapacity { option (gogoproto.goproto_stringer) = false; + // Total capacity of the disk used by the store, including space used by the + // operating system and other applications. optional int64 capacity = 1 [(gogoproto.nullable) = false]; + // Available space remaining on the disk used by the store. optional int64 available = 2 [(gogoproto.nullable) = false]; + // Amount of disk space used by the data in the CockroachDB store. Note that + // this is going to be less than (capacity - available), because those two + // fields consider the entire disk and everything on it, while this only + // tracks the store's disk usage. + optional int64 used = 8 [(gogoproto.nullable) = false]; // Amount of logical bytes stored in the store, ignoring RocksDB space // overhead. Useful for rebalancing so that moving a replica from one store // to another actually removes its bytes from the source store even though diff --git a/pkg/server/status/recorder_test.go b/pkg/server/status/recorder_test.go index b9a6d383acaa..88ea8f2f2089 100644 --- a/pkg/server/status/recorder_test.go +++ b/pkg/server/status/recorder_test.go @@ -119,6 +119,7 @@ func TestMetricsRecorder(t *testing.T) { Capacity: roachpb.StoreCapacity{ Capacity: 100, Available: 50, + Used: 50, }, } storeDesc2 := roachpb.StoreDescriptor{ @@ -126,6 +127,7 @@ func TestMetricsRecorder(t *testing.T) { Capacity: roachpb.StoreCapacity{ Capacity: 200, Available: 75, + Used: 125, }, } diff --git a/pkg/storage/engine/rocksdb.go b/pkg/storage/engine/rocksdb.go index cf76321a4131..94575489ad58 100644 --- a/pkg/storage/engine/rocksdb.go +++ b/pkg/storage/engine/rocksdb.go @@ -636,16 +636,6 @@ func (r *RocksDB) Capacity() (roachpb.StoreCapacity, error) { fsuTotal := int64(fileSystemUsage.Total) fsuAvail := int64(fileSystemUsage.Avail) - // If no size limitation have been placed on the store size or if the - // limitation is greater than what's available, just return the actual - // totals. - if r.cfg.MaxSizeBytes == 0 || r.cfg.MaxSizeBytes >= fsuTotal || r.cfg.Dir == "" { - return roachpb.StoreCapacity{ - Capacity: fsuTotal, - Available: fsuAvail, - }, nil - } - // Find the total size of all the files in the r.dir and all its // subdirectories. var totalUsedBytes int64 @@ -661,6 +651,17 @@ func (r *RocksDB) Capacity() (roachpb.StoreCapacity, error) { return roachpb.StoreCapacity{}, errOuter } + // If no size limitation have been placed on the store size or if the + // limitation is greater than what's available, just return the actual + // totals. + if r.cfg.MaxSizeBytes == 0 || r.cfg.MaxSizeBytes >= fsuTotal || r.cfg.Dir == "" { + return roachpb.StoreCapacity{ + Capacity: fsuTotal, + Available: fsuAvail, + Used: totalUsedBytes, + }, nil + } + available := r.cfg.MaxSizeBytes - totalUsedBytes if available > fsuAvail { available = fsuAvail @@ -672,6 +673,7 @@ func (r *RocksDB) Capacity() (roachpb.StoreCapacity, error) { return roachpb.StoreCapacity{ Capacity: r.cfg.MaxSizeBytes, Available: available, + Used: totalUsedBytes, }, nil } diff --git a/pkg/storage/metrics.go b/pkg/storage/metrics.go index bb89eaa2aea2..820082c4643b 100644 --- a/pkg/storage/metrics.go +++ b/pkg/storage/metrics.go @@ -144,6 +144,9 @@ var ( metaAvailable = metric.Metadata{ Name: "capacity.available", Help: "Available storage capacity"} + metaUsed = metric.Metadata{ + Name: "capacity.used", + Help: "Used storage capacity"} metaReserved = metric.Metadata{ Name: "capacity.reserved", Help: "Capacity reserved for snapshots"} @@ -517,6 +520,7 @@ type StoreMetrics struct { LastUpdateNanos *metric.Gauge Capacity *metric.Gauge Available *metric.Gauge + Used *metric.Gauge Reserved *metric.Counter SysBytes *metric.Gauge SysCount *metric.Gauge @@ -708,6 +712,7 @@ func newStoreMetrics(histogramWindow time.Duration) *StoreMetrics { LastUpdateNanos: metric.NewGauge(metaLastUpdateNanos), Capacity: metric.NewGauge(metaCapacity), Available: metric.NewGauge(metaAvailable), + Used: metric.NewGauge(metaUsed), Reserved: metric.NewCounter(metaReserved), SysBytes: metric.NewGauge(metaSysBytes), SysCount: metric.NewGauge(metaSysCount), diff --git a/pkg/storage/store.go b/pkg/storage/store.go index 9eceb3f05d4d..cdc3f447dc87 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -3920,6 +3920,7 @@ func (s *Store) updateCapacityGauges() error { } s.metrics.Capacity.Update(desc.Capacity.Capacity) s.metrics.Available.Update(desc.Capacity.Available) + s.metrics.Used.Update(desc.Capacity.Used) return nil } diff --git a/pkg/ui/src/js/protos.d.ts b/pkg/ui/src/js/protos.d.ts index c25ac5d10e81..a109c7c3807f 100644 --- a/pkg/ui/src/js/protos.d.ts +++ b/pkg/ui/src/js/protos.d.ts @@ -16226,6 +16226,8 @@ export namespace cockroach { type StoreCapacity$Properties = { capacity?: Long; available?: Long; + used?: Long; + logical_bytes?: Long; range_count?: number; lease_count?: number; writes_per_second?: number; @@ -16261,6 +16263,18 @@ export namespace cockroach { */ public available: Long; + /** + * StoreCapacity used. + * @type {Long} + */ + public used: Long; + + /** + * StoreCapacity logical_bytes. + * @type {Long} + */ + public logical_bytes: Long; + /** * StoreCapacity range_count. * @type {number} diff --git a/pkg/ui/src/js/protos.js b/pkg/ui/src/js/protos.js index 792d88600add..20ec35805a63 100644 --- a/pkg/ui/src/js/protos.js +++ b/pkg/ui/src/js/protos.js @@ -29737,6 +29737,8 @@ export const cockroach = $root.cockroach = (() => { * @type {Object} * @property {Long} [capacity] StoreCapacity capacity. * @property {Long} [available] StoreCapacity available. + * @property {Long} [used] StoreCapacity used. + * @property {Long} [logical_bytes] StoreCapacity logical_bytes. * @property {number} [range_count] StoreCapacity range_count. * @property {number} [lease_count] StoreCapacity lease_count. * @property {number} [writes_per_second] StoreCapacity writes_per_second. @@ -29769,6 +29771,18 @@ export const cockroach = $root.cockroach = (() => { */ StoreCapacity.prototype.available = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** + * StoreCapacity used. + * @type {Long} + */ + StoreCapacity.prototype.used = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * StoreCapacity logical_bytes. + * @type {Long} + */ + StoreCapacity.prototype.logical_bytes = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * StoreCapacity range_count. * @type {number} @@ -29831,6 +29845,10 @@ export const cockroach = $root.cockroach = (() => { $root.cockroach.roachpb.Percentiles.encode(message.bytes_per_replica, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.writes_per_replica != null && message.hasOwnProperty("writes_per_replica")) $root.cockroach.roachpb.Percentiles.encode(message.writes_per_replica, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.used != null && message.hasOwnProperty("used")) + writer.uint32(/* id 8, wireType 0 =*/64).int64(message.used); + if (message.logical_bytes != null && message.hasOwnProperty("logical_bytes")) + writer.uint32(/* id 9, wireType 0 =*/72).int64(message.logical_bytes); return writer; }; @@ -29865,6 +29883,12 @@ export const cockroach = $root.cockroach = (() => { case 2: message.available = reader.int64(); break; + case 8: + message.used = reader.int64(); + break; + case 9: + message.logical_bytes = reader.int64(); + break; case 3: message.range_count = reader.int32(); break; @@ -29915,6 +29939,12 @@ export const cockroach = $root.cockroach = (() => { if (message.available != null && message.hasOwnProperty("available")) if (!$util.isInteger(message.available) && !(message.available && $util.isInteger(message.available.low) && $util.isInteger(message.available.high))) return "available: integer|Long expected"; + if (message.used != null && message.hasOwnProperty("used")) + if (!$util.isInteger(message.used) && !(message.used && $util.isInteger(message.used.low) && $util.isInteger(message.used.high))) + return "used: integer|Long expected"; + if (message.logical_bytes != null && message.hasOwnProperty("logical_bytes")) + if (!$util.isInteger(message.logical_bytes) && !(message.logical_bytes && $util.isInteger(message.logical_bytes.low) && $util.isInteger(message.logical_bytes.high))) + return "logical_bytes: integer|Long expected"; if (message.range_count != null && message.hasOwnProperty("range_count")) if (!$util.isInteger(message.range_count)) return "range_count: integer expected"; @@ -29964,6 +29994,24 @@ export const cockroach = $root.cockroach = (() => { message.available = object.available; else if (typeof object.available === "object") message.available = new $util.LongBits(object.available.low >>> 0, object.available.high >>> 0).toNumber(); + if (object.used != null) + if ($util.Long) + (message.used = $util.Long.fromValue(object.used)).unsigned = false; + else if (typeof object.used === "string") + message.used = parseInt(object.used, 10); + else if (typeof object.used === "number") + message.used = object.used; + else if (typeof object.used === "object") + message.used = new $util.LongBits(object.used.low >>> 0, object.used.high >>> 0).toNumber(); + if (object.logical_bytes != null) + if ($util.Long) + (message.logical_bytes = $util.Long.fromValue(object.logical_bytes)).unsigned = false; + else if (typeof object.logical_bytes === "string") + message.logical_bytes = parseInt(object.logical_bytes, 10); + else if (typeof object.logical_bytes === "number") + message.logical_bytes = object.logical_bytes; + else if (typeof object.logical_bytes === "object") + message.logical_bytes = new $util.LongBits(object.logical_bytes.low >>> 0, object.logical_bytes.high >>> 0).toNumber(); if (object.range_count != null) message.range_count = object.range_count | 0; if (object.lease_count != null) @@ -30018,6 +30066,16 @@ export const cockroach = $root.cockroach = (() => { object.writes_per_second = 0; object.bytes_per_replica = null; object.writes_per_replica = null; + if ($util.Long) { + let long = new $util.Long(0, 0, false); + object.used = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.used = options.longs === String ? "0" : 0; + if ($util.Long) { + let long = new $util.Long(0, 0, false); + object.logical_bytes = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.logical_bytes = options.longs === String ? "0" : 0; } if (message.capacity != null && message.hasOwnProperty("capacity")) if (typeof message.capacity === "number") @@ -30039,6 +30097,16 @@ export const cockroach = $root.cockroach = (() => { object.bytes_per_replica = $root.cockroach.roachpb.Percentiles.toObject(message.bytes_per_replica, options); if (message.writes_per_replica != null && message.hasOwnProperty("writes_per_replica")) object.writes_per_replica = $root.cockroach.roachpb.Percentiles.toObject(message.writes_per_replica, options); + if (message.used != null && message.hasOwnProperty("used")) + if (typeof message.used === "number") + object.used = options.longs === String ? String(message.used) : message.used; + else + object.used = options.longs === String ? $util.Long.prototype.toString.call(message.used) : options.longs === Number ? new $util.LongBits(message.used.low >>> 0, message.used.high >>> 0).toNumber() : message.used; + if (message.logical_bytes != null && message.hasOwnProperty("logical_bytes")) + if (typeof message.logical_bytes === "number") + object.logical_bytes = options.longs === String ? String(message.logical_bytes) : message.logical_bytes; + else + object.logical_bytes = options.longs === String ? $util.Long.prototype.toString.call(message.logical_bytes) : options.longs === Number ? new $util.LongBits(message.logical_bytes.low >>> 0, message.logical_bytes.high >>> 0).toNumber() : message.logical_bytes; return object; }; diff --git a/pkg/ui/src/redux/nodes.ts b/pkg/ui/src/redux/nodes.ts index e5f70123ba0d..15a2e622c9d3 100644 --- a/pkg/ui/src/redux/nodes.ts +++ b/pkg/ui/src/redux/nodes.ts @@ -127,6 +127,7 @@ const nodeSumsSelector = createSelector( dead: 0, decommissioned: 0, }, + capacityUsed: 0, capacityAvailable: 0, capacityTotal: 0, usedBytes: 0, @@ -156,6 +157,7 @@ const nodeSumsSelector = createSelector( break; } if (status !== LivenessStatus.DEAD) { + result.capacityUsed += n.metrics[MetricConstants.usedCapacity]; result.capacityAvailable += n.metrics[MetricConstants.availableCapacity]; result.capacityTotal += n.metrics[MetricConstants.capacity]; result.usedBytes += BytesUsed(n); diff --git a/pkg/ui/src/util/proto.ts b/pkg/ui/src/util/proto.ts index bc483eaea8f0..1fdf856ba0af 100644 --- a/pkg/ui/src/util/proto.ts +++ b/pkg/ui/src/util/proto.ts @@ -58,6 +58,7 @@ export namespace MetricConstants { export const lastUpdateNano: string = "lastupdatenanos"; export const capacity: string = "capacity"; export const availableCapacity: string = "capacity.available"; + export const usedCapacity: string = "capacity.used"; export const sysBytes: string = "sysbytes"; export const sysCount: string = "syscount"; @@ -87,6 +88,10 @@ const aggregateByteKeys = [ ]; export function BytesUsed(s: NodeStatus$Properties): number { + const usedCapacity = s.metrics[MetricConstants.usedCapacity] + if (usedCapacity != 0) { + return usedCapacity + } return _.sumBy(aggregateByteKeys, (key: string) => { return s.metrics[key]; }); diff --git a/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/overview.tsx b/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/overview.tsx index 857cb6424fbb..2d737ce7df46 100644 --- a/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/overview.tsx +++ b/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/overview.tsx @@ -98,19 +98,16 @@ export default function (props: GraphDashboardProps) {
Available
Free disk space available {tooltipSelection} to CockroachDB.
+
Used
+
Disk space used {tooltipSelection} by CockroachDB.
)} > - { - // TODO(mrtracy): We really want to display a used capacity - // stat, but that is not directly recorded. We either need to - // start directly recording it, or add the ability to create - // derived series. - } + , diff --git a/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/storage.tsx b/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/storage.tsx index ded6d581e47b..49b6f0166470 100644 --- a/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/storage.tsx +++ b/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/storage.tsx @@ -17,13 +17,8 @@ export default function (props: GraphDashboardProps) { > - { - // TODO(mrtracy): We really want to display a used capacity - // stat, but that is not directly recorded. We either need to - // start directly recording it, or add the ability to create - // derived series. - } + , diff --git a/pkg/ui/src/views/cluster/containers/nodeGraphs/summaryBar.tsx b/pkg/ui/src/views/cluster/containers/nodeGraphs/summaryBar.tsx index b07b22d2f29c..c9c75256e586 100644 --- a/pkg/ui/src/views/cluster/containers/nodeGraphs/summaryBar.tsx +++ b/pkg/ui/src/views/cluster/containers/nodeGraphs/summaryBar.tsx @@ -53,9 +53,9 @@ function ClusterNodeTotals (props: ClusterSummaryProps) { */ export default function(props: ClusterSummaryProps) { // Capacity math used in the summary status section. - const { capacityTotal, capacityAvailable } = props.nodesSummary.nodeSums; - const capacityUsed = capacityTotal - capacityAvailable; - const capacityPercent = capacityTotal !== 0 ? (capacityUsed / capacityTotal * 100) : 100; + const { capacityAvailable, capacityUsed } = props.nodesSummary.nodeSums; + const usableCapacity = capacityAvailable+capacityUsed + const capacityPercent = usableCapacity !== 0 ? (capacityUsed / (usableCapacity * 100)) : 100; return (
@@ -64,8 +64,8 @@ export default function(props: ClusterSummaryProps) { `${d3.format(".2f")(v)}%`}> - + diff --git a/pkg/ui/src/views/cluster/containers/nodeOverview/index.tsx b/pkg/ui/src/views/cluster/containers/nodeOverview/index.tsx index 6948493fe76d..bc269b4c3aec 100644 --- a/pkg/ui/src/views/cluster/containers/nodeOverview/index.tsx +++ b/pkg/ui/src/views/cluster/containers/nodeOverview/index.tsx @@ -111,6 +111,9 @@ class NodeOverview extends React.Component { Percentage(metrics[MetricConstants.underReplicatedRanges], metrics[MetricConstants.ranges])} /> + Bytes(metrics[MetricConstants.usedCapacity])} /> Bytes(metrics[MetricConstants.availableCapacity])} />