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

avoid information loss on .GoError() #2629

Merged
merged 6 commits into from
Sep 23, 2015
Merged

avoid information loss on .GoError() #2629

merged 6 commits into from
Sep 23, 2015

Conversation

tbg
Copy link
Member

@tbg tbg commented Sep 23, 2015

fixes #2628.

if e.Index == nil {
return 0, false
}
return (*Error)(e).Index.Index, true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why bother with the cast?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I used GetIndex() before. Changed.

@tbg tbg force-pushed the int_error branch 3 times, most recently from e1d8909 to c451a05 Compare September 23, 2015 08:32
@tbg
Copy link
Member Author

tbg commented Sep 23, 2015

PTAL. I actually cleaned up some more stuff in the vicinity (see third commit message), which brought some nice simplifications.

@tamird
Copy link
Contributor

tamird commented Sep 23, 2015

That these errors carry indexes into the batch in which they are contained is starting to feel pretty dirty to me. What's the long term plan here?

@@ -465,8 +465,6 @@ func TestStoreExecuteNoop(t *testing.T) {
}
}

// TestStoreErrorWithIndex verifies that an *errWithIndex returned from the
// replica is correctly translated into a *proto.Error with a corresponding
// Index. See the companion test TestBatchWithError.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is broken now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the test. TestBatchErrorWithIndex tests the same thing closer to
the source.

On Wed, Sep 23, 2015 at 10:53 AM, Tamir Duberstein <[email protected]

wrote:

In storage/store_test.go
#2629 (comment):

@@ -465,8 +465,6 @@ func TestStoreExecuteNoop(t *testing.T) {
}
}

-// TestStoreErrorWithIndex verifies that an *errWithIndex returned from the
-// replica is correctly translated into a *proto.Error with a corresponding
// Index. See the companion test TestBatchWithError.

this comment is broken now


Reply to this email directly or view it on GitHub
https://github.com/cockroachdb/cockroach/pull/2629/files#r40212652.

@tamird
Copy link
Contributor

tamird commented Sep 23, 2015

LGTM

@@ -192,6 +193,11 @@ enum TransactionRestart {
IMMEDIATE = 2;
}

// ErrPosition describes the position of an error in a Batch.
message ErrPosition {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a value to this message versus just embedding optional int32 index in the errors which require it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in proto3 primitive types are not nullable. there was a discussion on this in a previous PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved up the comment about that from message Error.

@petermattis
Copy link
Collaborator

LGTM

@bdarnell
Copy link
Contributor

LGTM. This change is definitely an improvement, but embedding the position doesn't sit well with me either. Is there something else we could do to provide the same functionality? For example, if ConditionalPut returned the key as well as the value, would that be enough for the SQL layer to construct the right error message for uniqueness violations?

@tamird
Copy link
Contributor

tamird commented Sep 23, 2015

@bdarnell yes, that would be enough for the SQL layer. However, I think in general we will still want an error -> operation mapping for batches.

@tbg
Copy link
Member Author

tbg commented Sep 23, 2015

The only location in which they're really "on" the batch is when they're on
the wire, but everywhere else they're separate. In the end, I would like to
completely remove the error field from *proto.BatchResponse and just send
a proto.BatchResponseOrError over the wire, so that you never see both a
response and an error.

On Wed, Sep 23, 2015 at 10:52 AM, Tamir Duberstein <[email protected]

wrote:

That these errors carry indexes into the batch in which they are contained
is starting to feel pretty dirty to me. What's the long term plan here?


Reply to this email directly or view it on GitHub
#2629 (comment)
.

@tbg
Copy link
Member Author

tbg commented Sep 23, 2015

For example, if ConditionalPut returned the key as well as the value

Yes, I thought about that too but it seemed fairly inflexible. With hindsight, while I think this change makes indexed errors workable, I agree it's not the cream of the crop yet and it might've been better to start small and just add a Key to proto.ConditionalPutError. Well, damage is done now. I'm sure there's going to be another iteration.

tbg added 6 commits September 23, 2015 15:36
remove errWithIndex, which was used in `./storage` to wrap a batch
execution error along with the position at which it occurred.
That construct was prone to bugs and the later unwrapping into
a proto.Error meant that you could end up with a proto.Error
which carried more information than its associated ErrorDetail
(for example, `errWithIndex{err: ConditionalPutError, index:1}`
would translate into `proto.Error{Index: 1, Detail: ConditionalPutError}`
but since `ConditionalPutError` is a valid `ErrorDetail`, `GoError()`
would then return exactly that, losing the index.

Now an error whose relative position could be relevant at some future
point needs to implement `proto.IndexedError`, and then everything will
work as expected, regardless of whether the original error is an
`ErrorDetail` or not.
this is now possible since the index information is
stored on the `ErrorDetail` itself, so exposing the
`GoError()` only is sufficient.
plus some comment fixes
tbg added a commit that referenced this pull request Sep 23, 2015
avoid information loss on .GoError()
@tbg tbg merged commit 9b2465d into cockroachdb:master Sep 23, 2015
@tbg tbg deleted the int_error branch September 23, 2015 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure in CI build 7857
4 participants