Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
72435: storage,server,sql: capture and expose filesystem details in store descriptors r=dhartunian,stevendanna a=knz

Fixes cockroachdb#64326. 

See the individual commits for details.

Example use:

```
root@:26257/defaultdb> select node_id, store_id,
  properties->'file_store_properties'->'fs_type' as fs
  from crdb_internal.kv_store_status;

  node_id | store_id |  fs
----------+----------+--------
        1 |        1 | "zfs"
(1 row)
```

This also enables collecting the filesystem information in the output
of `debug zip`.

Release note (sql change): Some filesystem-level properties are now
exposed in `crdb_internal.kv_store_status`. Note that the particular
fields and layout are not stabilized yet.

Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
  • Loading branch information
craig[bot] and knz committed Nov 10, 2021
2 parents 2de17e7 + c0b2bf4 commit bea7026
Show file tree
Hide file tree
Showing 16 changed files with 1,657 additions and 782 deletions.
2 changes: 2 additions & 0 deletions docs/generated/http/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ descriptor and store capacity.
| attrs | [cockroach.roachpb.Attributes](#cockroach.server.serverpb.NodesResponseExternal-cockroach.roachpb.Attributes) | | | [reserved](#support-status) |
| node | [NodeDescriptor](#cockroach.server.serverpb.NodesResponseExternal-cockroach.server.serverpb.NodeDescriptor) | | | [reserved](#support-status) |
| capacity | [cockroach.roachpb.StoreCapacity](#cockroach.server.serverpb.NodesResponseExternal-cockroach.roachpb.StoreCapacity) | | | [reserved](#support-status) |
| properties | [cockroach.roachpb.StoreProperties](#cockroach.server.serverpb.NodesResponseExternal-cockroach.roachpb.StoreProperties) | | | [reserved](#support-status) |



Expand Down Expand Up @@ -952,6 +953,7 @@ descriptor and store capacity.
| attrs | [cockroach.roachpb.Attributes](#cockroach.server.serverpb.NodeResponse-cockroach.roachpb.Attributes) | | | [reserved](#support-status) |
| node | [NodeDescriptor](#cockroach.server.serverpb.NodeResponse-cockroach.server.serverpb.NodeDescriptor) | | | [reserved](#support-status) |
| capacity | [cockroach.roachpb.StoreCapacity](#cockroach.server.serverpb.NodeResponse-cockroach.roachpb.StoreCapacity) | | | [reserved](#support-status) |
| properties | [cockroach.roachpb.StoreProperties](#cockroach.server.serverpb.NodeResponse-cockroach.roachpb.StoreProperties) | | | [reserved](#support-status) |



Expand Down
16 changes: 11 additions & 5 deletions pkg/kv/kvserver/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import (
"github.com/cockroachdb/errors"
"github.com/cockroachdb/logtags"
"github.com/cockroachdb/redact"
"go.etcd.io/etcd/raft/v3"
raft "go.etcd.io/etcd/raft/v3"
"golang.org/x/time/rate"
)

Expand Down Expand Up @@ -2510,6 +2510,11 @@ func (s *Store) Attrs() roachpb.Attributes {
return s.engine.Attrs()
}

// Properties returns the properties of the underlying store.
func (s *Store) Properties() roachpb.StoreProperties {
return s.engine.Properties()
}

// Capacity returns the capacity of the underlying storage engine. Note that
// this does not include reservations.
// Note that Capacity() has the side effect of updating some of the store's
Expand Down Expand Up @@ -2615,10 +2620,11 @@ func (s *Store) Descriptor(ctx context.Context, useCached bool) (*roachpb.StoreD

// Initialize the store descriptor.
return &roachpb.StoreDescriptor{
StoreID: s.Ident.StoreID,
Attrs: s.Attrs(),
Node: *s.nodeDesc,
Capacity: capacity,
StoreID: s.Ident.StoreID,
Attrs: s.Attrs(),
Node: *s.nodeDesc,
Capacity: capacity,
Properties: s.Properties(),
}, nil
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/roachpb/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,20 @@ func (p Percentiles) SafeFormat(w redact.SafePrinter, _ rune) {
p.P10, p.P25, p.P50, p.P75, p.P90, p.PMax)
}

func (sc FileStoreProperties) String() string {
return redact.StringWithoutMarkers(sc)
}

// SafeFormat implements the redact.SafeFormatter interface.
func (sc FileStoreProperties) SafeFormat(w redact.SafePrinter, _ rune) {
w.Printf("{path=%s, fs=%s, blkdev=%s, mnt=%s opts=%s}",
sc.Path,
redact.SafeString(sc.FsType),
sc.BlockDevice,
sc.MountPoint,
sc.MountOptions)
}

// String returns a string representation of the StoreCapacity.
func (sc StoreCapacity) String() string {
return redact.StringWithoutMarkers(sc)
Expand Down
817 changes: 714 additions & 103 deletions pkg/roachpb/metadata.pb.go

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions pkg/roachpb/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,34 @@ message StoreCapacity {
optional Percentiles writes_per_replica = 7 [(gogoproto.nullable) = false];
}

// StoreProperties contains configuration and OS-level details for a storage device.
message StoreProperties {
// encrypted indicates whether the store is encrypted.
optional bool encrypted = 1 [(gogoproto.nullable) = false];
// read_only indicates whether the store is attached read_only.
optional bool read_only = 2 [(gogoproto.nullable) = false];

// disk_properties reports details about the underlying filesystem,
// when the store is supported by a file store. Unset otherwise.
optional FileStoreProperties file_store_properties = 3;
}

// FileStoreProperties contains configuration and OS-level details for a file store.
message FileStoreProperties {
option (gogoproto.goproto_stringer) = false;

// path reports the configured filesystem path for the store.
optional string path = 1 [(gogoproto.nullable) = false];
// fs_type reports the external filesystem type (ufs, ext4, etc), if known.
optional string fs_type = 2 [(gogoproto.nullable) = false];
// block_device reports which block devices supports the filesystem, if known.
optional string block_device = 3 [(gogoproto.nullable) = false];
// mount_point reports the mount point of the filesystem, if known.
optional string mount_point = 4 [(gogoproto.nullable) = false];
// mount_options reports the mount options, if known.
optional string mount_options = 5 [(gogoproto.nullable) = false];
}

// NodeDescriptor holds details on node physical/network topology.
message NodeDescriptor {
option (gogoproto.equal) = true;
Expand Down Expand Up @@ -369,6 +397,7 @@ message StoreDescriptor {
optional Attributes attrs = 2 [(gogoproto.nullable) = false];
optional NodeDescriptor node = 3 [(gogoproto.nullable) = false];
optional StoreCapacity capacity = 4 [(gogoproto.nullable) = false];
optional StoreProperties properties = 5 [(gogoproto.nullable) = false];
}

// StoreDeadReplicas holds a storeID and a list of dead replicas on that store.
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
if err != nil {
return Engines{}, err
}
details = append(details, redact.Sprintf("store %d: %+v", i, e.Properties()))
engines = append(engines, e)
} else {
e, err := storage.Open(ctx,
Expand Down Expand Up @@ -604,6 +605,7 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
if err != nil {
return Engines{}, err
}
details = append(details, redact.Sprintf("store %d: %+v", i, eng.Properties()))
engines = append(engines, eng)
}
}
Expand Down
Loading

0 comments on commit bea7026

Please sign in to comment.