Skip to content

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

@irfansharif

Description

@irfansharif

We currently have code in CRDB that looks like the following:

cockroach/pkg/cli/error.go

Lines 356 to 364 in 9ba4404

// Are we trying to re-initialize an initialized cluster?
if strings.Contains(err.Error(), server.ErrClusterInitialized.Error()) {
// We really want to use errors.Is() here but this would require
// error serialization support in gRPC.
// This is not yet performed in CockroachDB even though the error
// library now has infrastructure to do so, see:
// https://github.com/cockroachdb/errors/pull/14
return server.ErrClusterInitialized
}

We're essentially string matching on the specific error and using that in our control flow; it makes for fragile code. As of cockroachdb/errors#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cc-enablementPertains to current CC production issues or short-term projectsA-error-handlingError messages, error propagations/annotationsA-kv-serverRelating to the KV-level RPC serverA-server-networkingPertains to network addressing,routing,initializationC-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.T-kvKV TeamT-server-and-securityDB Server & Security

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions