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)) 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)