Skip to content

Commit

Permalink
storage/engine: output result even on cmdGet error
Browse files Browse the repository at this point in the history
cmdScan was already doing this, so we should be consistent or it becomes
confusing why scan results show up on errors cases but not get results.
  • Loading branch information
nvanbenschoten committed Jan 31, 2020
1 parent a25a9c9 commit 7759868
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/storage/engine/mvcc_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,9 @@ func cmdGet(e *evalCtx) error {
opts.FailOnMoreRecent = true
}
val, intent, err := MVCCGet(e.ctx, e.engine, key, ts, opts)
if err != nil {
return err
}
// NB: the error is returned below. This ensures the test can
// ascertain no result is populated in the intent when an error
// occurs.
if intent != nil {
fmt.Fprintf(e.results.buf, "get: %v -> intent {%s} %s\n", key, intent.Txn, intent.Status)
}
Expand All @@ -613,7 +613,7 @@ func cmdGet(e *evalCtx) error {
} else {
fmt.Fprintf(e.results.buf, "get: %v -> <no data>\n", key)
}
return nil
return err
}

func cmdIncrement(e *evalCtx) error {
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/engine/testdata/mvcc_histories/empty_key
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
run error
get ts=0,1 k=
----
get: /Min -> <no data>
error: (*errors.fundamental:) attempted access to empty key

run error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data: "k"/0.000000001,0 -> /BYTES/v
run error
get k=k ts=-1
----
get: "k" -> <no data>
error: (*withstack.withStack:) cannot write to "k" at timestamp -0.000000001,0


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ get: "k1" -> <no data>
run error
get k=k1 ts=9,0 failOnMoreRecent
----
get: "k1" -> <no data>
error: (*roachpb.WriteTooOldError:) WriteTooOldError: write at timestamp 0.000000009,0 too old; wrote at 0.000000010,1

run ok
Expand Down Expand Up @@ -97,26 +98,31 @@ get: "k2" -> <no data>
run error
get k=k2 ts=9,0 failOnMoreRecent
----
get: "k2" -> <no data>
error: (*roachpb.WriteIntentError:) conflicting intents on "k2"

run error
get k=k2 ts=10,0
----
get: "k2" -> <no data>
error: (*roachpb.WriteIntentError:) conflicting intents on "k2"

run error
get k=k2 ts=10,0 failOnMoreRecent
----
get: "k2" -> <no data>
error: (*roachpb.WriteIntentError:) conflicting intents on "k2"

run error
get k=k2 ts=11,0
----
get: "k2" -> <no data>
error: (*roachpb.WriteIntentError:) conflicting intents on "k2"

run error
get k=k2 ts=11,0 failOnMoreRecent
----
get: "k2" -> <no data>
error: (*roachpb.WriteIntentError:) conflicting intents on "k2"

run ok
Expand Down Expand Up @@ -159,6 +165,7 @@ error: (*roachpb.WriteIntentError:) conflicting intents on "k2"
run error
get k=k1 ts=9,0 inconsistent failOnMoreRecent
----
get: "k1" -> <no data>
error: (*withstack.withStack:) cannot allow inconsistent reads with fail on more recent option

run error
Expand Down

0 comments on commit 7759868

Please sign in to comment.