Skip to content

release-19.2: server: add metric for number of disk stalls detected #41475

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

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions pkg/server/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/logtags"
"github.com/opentracing/opentracing-go"
opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -78,6 +78,13 @@ var (
Measurement: "Batch KV Requests",
Unit: metric.Unit_COUNT,
}

metaDiskStalls = metric.Metadata{
Name: "engine.stalls",
Help: "Number of disk stalls detected on this node",
Measurement: "Disk stalls detected",
Unit: metric.Unit_COUNT,
}
)

// Cluster settings.
Expand Down Expand Up @@ -105,16 +112,18 @@ var (
)

type nodeMetrics struct {
Latency *metric.Histogram
Success *metric.Counter
Err *metric.Counter
Latency *metric.Histogram
Success *metric.Counter
Err *metric.Counter
DiskStalls *metric.Counter
}

func makeNodeMetrics(reg *metric.Registry, histogramWindow time.Duration) nodeMetrics {
nm := nodeMetrics{
Latency: metric.NewLatency(metaExecLatency, histogramWindow),
Success: metric.NewCounter(metaExecSuccess),
Err: metric.NewCounter(metaExecError),
Latency: metric.NewLatency(metaExecLatency, histogramWindow),
Success: metric.NewCounter(metaExecSuccess),
Err: metric.NewCounter(metaExecError),
DiskStalls: metric.NewCounter(metaDiskStalls),
}
reg.AddMetricStruct(nm)
return nm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/storage/engine"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
)

Expand All @@ -35,8 +34,8 @@ var maxSyncDurationFatalOnExceeded = envutil.EnvOrDefaultBool("COCKROACH_ENGINE_
// startAssertEngineHealth starts a goroutine that periodically verifies that
// syncing the engines is possible within maxSyncDuration. If not,
// the process is terminated (with an attempt at a descriptive message).
func startAssertEngineHealth(ctx context.Context, stopper *stop.Stopper, engines []engine.Engine) {
stopper.RunWorker(ctx, func(ctx context.Context) {
func (n *Node) startAssertEngineHealth(ctx context.Context, engines []engine.Engine) {
n.stopper.RunWorker(ctx, func(ctx context.Context) {
t := timeutil.NewTimer()
t.Reset(0)

Expand All @@ -45,8 +44,8 @@ func startAssertEngineHealth(ctx context.Context, stopper *stop.Stopper, engines
case <-t.C:
t.Read = true
t.Reset(10 * time.Second)
assertEngineHealth(ctx, engines, maxSyncDuration)
case <-stopper.ShouldQuiesce():
n.assertEngineHealth(ctx, engines, maxSyncDuration)
case <-n.stopper.ShouldQuiesce():
return
}
}
Expand All @@ -58,10 +57,13 @@ func guaranteedExitFatal(ctx context.Context, msg string, args ...interface{}) {
log.Shout(ctx, log.Severity_FATAL, fmt.Sprintf(msg, args...))
}

func assertEngineHealth(ctx context.Context, engines []engine.Engine, maxDuration time.Duration) {
func (n *Node) assertEngineHealth(
ctx context.Context, engines []engine.Engine, maxDuration time.Duration,
) {
for _, eng := range engines {
func() {
t := time.AfterFunc(maxDuration, func() {
n.metrics.DiskStalls.Inc(1)
var stats string
if rocks, ok := eng.(*engine.RocksDB); ok {
stats = "\n" + rocks.GetCompactionStats()
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import (
"github.com/cockroachdb/logtags"
raven "github.com/getsentry/raven-go"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/opentracing/opentracing-go"
opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -1270,7 +1270,7 @@ func (s *Server) Start(ctx context.Context) error {
}
s.stopper.AddCloser(&s.engines)

startAssertEngineHealth(ctx, s.stopper, s.engines)
s.node.startAssertEngineHealth(ctx, s.engines)

// Write listener info files early in the startup sequence. `listenerInfo` has a comment.
listenerFiles := listenerInfo{
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ func TestChartCatalogMetrics(t *testing.T) {
}

if len(undefinedMetrics) > 0 {
t.Fatalf(`The following metrics need are no longer present and need to be removed
t.Fatalf(`The following metrics need are no longer present and need to be removed
from the chart catalog (pkg/ts/chart_catalog.go):%v`, undefinedMetrics)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/ts/catalog/chart_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,13 @@ var charts = []sectionDescription{
"exec.success",
},
},
{
Title: "Storage Engine Stalls",
Downsampler: DescribeAggregator_MAX,
Rate: DescribeDerivative_NON_NEGATIVE_DERIVATIVE,
Percentiles: false,
Metrics: []string{"engine.stalls"},
},
},
},
{
Expand Down