From 44f4c62236cdf98eb1f4b17b078f785c7a155bed Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Mon, 25 Jan 2021 12:23:33 -0800 Subject: [PATCH 1/2] Calling Discard only adds to txn_discards metric, not txn_aborts. --- worker/mutation.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/worker/mutation.go b/worker/mutation.go index 49e8205d9db..e74f91ef8d0 100644 --- a/worker/mutation.go +++ b/worker/mutation.go @@ -767,9 +767,12 @@ func typeSanityCheck(t *pb.TypeUpdate) error { func CommitOverNetwork(ctx context.Context, tc *api.TxnContext) (uint64, error) { ctx, span := otrace.StartSpan(ctx, "worker.CommitOverNetwork") defer span.End() + + clientDiscard := false if tc.Aborted { // The client called Discard ostats.Record(ctx, x.TxnDiscards.M(1)) + clientDiscard = true } pl := groups().Leader(0) @@ -789,8 +792,10 @@ func CommitOverNetwork(ctx context.Context, tc *api.TxnContext) (uint64, error) span.Annotate(attributes, "") if tctx.Aborted || tctx.CommitTs == 0 { - // The server aborted the txn (not the client) - ostats.Record(ctx, x.TxnAborts.M(1)) + if !clientDiscard { + // The server aborted the txn (not the client) + ostats.Record(ctx, x.TxnAborts.M(1)) + } return 0, dgo.ErrAborted } ostats.Record(ctx, x.TxnCommits.M(1)) From f6698da53b788ac6b63d882f2d52ed4bb043abc0 Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Mon, 25 Jan 2021 12:30:29 -0800 Subject: [PATCH 2/2] chore: Update help text in metrics descriptions. --- x/metrics.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/metrics.go b/x/metrics.go index 84bc05c9320..91936530fa2 100644 --- a/x/metrics.go +++ b/x/metrics.go @@ -102,12 +102,12 @@ var ( // TxnCommits records count of committed transactions. TxnCommits = stats.Int64("txn_commits_total", "Number of transaction commits", stats.UnitDimensionless) - // TxnDiscards records count of discarded transactions. + // TxnDiscards records count of discarded transactions by the client. TxnDiscards = stats.Int64("txn_discards_total", - "Number of transaction discards", stats.UnitDimensionless) - // TxnAborts records count of aborted transactions. + "Number of transaction discards by the client", stats.UnitDimensionless) + // TxnAborts records count of aborted transactions by the server. TxnAborts = stats.Int64("txn_aborts_total", - "Number of transaction aborts", stats.UnitDimensionless) + "Number of transaction aborts by the server", stats.UnitDimensionless) // PBlockHitRatio records the hit ratio of posting store block cache. PBlockHitRatio = stats.Float64("hit_ratio_postings_block", "Hit ratio of p store block cache", stats.UnitDimensionless)