Skip to content
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

fix: Calling Discard only adds to txn_discards metric, not txn_aborts. #7365

Merged
merged 2 commits into from
Jan 25, 2021
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
9 changes: 7 additions & 2 deletions worker/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions x/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down