cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.09k stars 3.8k forks source link

kv,server: implement error serialization support in gRPC #56208

Open irfansharif opened 3 years ago

irfansharif commented 3 years ago

We currently have code in CRDB that looks like the following: https://github.com/cockroachdb/cockroach/blob/9ba4404813cd68b5adf3e16cfb589eb355a778cb/pkg/cli/error.go#L356-L364

We're essentially string matching on the specific error and using that in our control flow; it makes for fragile code. As of https://github.com/cockroachdb/errors/pull/14, our errors package now has the infrastructure to support error serialization in gRPC. It'd be nice to implement it and start promoting this errors.Is(...) usage pattern across RPC boundaries, in the same way we do for "local" errors.

Jira issue: CRDB-2971

ajwerner commented 3 years ago

Is there anything blocking this? This would be great!

irfansharif commented 3 years ago

+cc @erikgrinaker.

andreimatei commented 3 years ago

Can someone (@ajwerner ?) please spell out how this issue depends on #56378 (as per https://github.com/cockroachdb/cockroach/issues/56378#issuecomment-780923105) ?

ajwerner commented 3 years ago

I don't know about https://github.com/cockroachdb/cockroach/issues/56378. I was just hoping to fix some string matching on grpc errors when I stumbled into this.

knz commented 3 years ago

@erikgrinaker I think you've completed this right? Is there still work to do?

erikgrinaker commented 3 years ago

Lots of work to do. We will basically have to add Protobuf serialization support for all relevant structured errors, make sure they can reliably traverse gRPC boundaries, and replace all the error string matching we currently do with structured error matching.

github-actions[bot] commented 1 year ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!