Skip to content

Commit

Permalink
kv: attach txn to error from detectIntentMissingDueToIntentResolution
Browse files Browse the repository at this point in the history
Fixes #53189.
Fixes #53282.
Fixes #53285.
Fixes #53469.

3dcb6f1 improved the detection of missing intents during parallel commit
attempts to distinguish between certain classes of ambiguous errors and
transaction aborted errors. This was a nice improvement, as it
dramatically reduced the number of situations where we returned
ambiguous errors during normal operation (see #52566).

However, in introducing a new location where transaction retry errors
could be generated, it accidentally violated the invariant that all
transaction retry errors have transaction protos attached to them. This
was causing panics in TPC-C roachtests. This commit fixes this issue by
properly attaching transaction protos to these new errors, along with
any others returned from `detectIntentMissingDueToIntentResolution`.

Release justification: bug fix
  • Loading branch information
nvanbenschoten committed Aug 31, 2020
1 parent 410616f commit 5430170
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/kv/kvclient/kvcoord/dist_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ func (ds *DistSender) divideAndSendParallelCommit(
// to intent resolution and can be safely ignored.
ignoreMissing, err = ds.detectIntentMissingDueToIntentResolution(ctx, br.Txn)
if err != nil {
return nil, roachpb.NewError(err)
return nil, roachpb.NewErrorWithTxn(err, br.Txn)
}
}
if !ignoreMissing {
Expand Down
5 changes: 5 additions & 0 deletions pkg/kv/kvclient/kvcoord/dist_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,11 @@ func TestParallelCommitsDetectIntentMissingCause(t *testing.T) {
if !testutils.IsPError(pErr, regexp.QuoteMeta(test.expErr)) {
t.Fatalf("expected error %q; found %v", test.expErr, pErr)
}
expErr := txn.Clone()
expErr.Status = roachpb.STAGING
if !reflect.DeepEqual(expErr, pErr.GetTxn()) {
t.Fatalf("expected txn %v on error, found %v", expErr, pErr.GetTxn())
}
}
})
}
Expand Down

0 comments on commit 5430170

Please sign in to comment.