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

vendor: can't upgrade to grpc-go v1.34 #60531

Closed
stevendanna opened this issue Feb 12, 2021 · 3 comments · Fixed by #61333
Closed

vendor: can't upgrade to grpc-go v1.34 #60531

stevendanna opened this issue Feb 12, 2021 · 3 comments · Fixed by #61333
Labels
C-investigation Further steps needed to qualify. C-label will change.

Comments

@stevendanna
Copy link
Collaborator

Describe the problem

Cockroach built with grpc-go v1.34 panics shortly after start with the following error when running ./cockroach demo:

panic: field cockroach.rpc.PingRequest.ping has invalid type: got string, want pointer [recovered]
        panic: field cockroach.rpc.PingRequest.ping has invalid type: got string, want pointer [recovered]
        panic: field cockroach.rpc.PingRequest.ping has invalid type: got string, want pointer

goroutine 6034 [running]:
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).Recover(0xc000b5e540, 0x91db960, 0xc0003ca9c0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:231 +0x126
panic(0x7c5cf40, 0xc000e7e9d0)
        /usr/local/Cellar/go/1.15.7_1/libexec/src/runtime/panic.go:969 +0x1b9
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).Recover(0xc000b5e540, 0x91db960, 0xc0003ca9c0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:231 +0x126
panic(0x7c5cf40, 0xc000e7e9d0)
        /usr/local/Cellar/go/1.15.7_1/libexec/src/runtime/panic.go:969 +0x1b9
google.golang.org/protobuf/internal/impl.fieldInfoForScalar(0x932f640, 0xc0021eae00, 0x7b876a7, 0x4, 0x0, 0x0, 0x932f760, 0x7c5cf40, 0x7b876ad, 0x2c, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go:228 +0x7d7
google.golang.org/protobuf/internal/impl.(*MessageInfo).makeKnownFieldsFunc(0xc002152000, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xc002544150, 0xc002544180, 0xc0025441b0, 0xc0025441e0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go:67 +0x97d
google.golang.org/protobuf/internal/impl.(*MessageInfo).makeReflectFuncs(0xc002152000, 0x932f760, 0x829db40, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xc002544150, 0xc002544180, 0xc0025441b0, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go:36 +0x65
google.golang.org/protobuf/internal/impl.(*MessageInfo).initOnce(0xc002152000)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message.go:90 +0x192
google.golang.org/protobuf/internal/impl.(*MessageInfo).init(...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message.go:72
google.golang.org/protobuf/internal/impl.(*messageReflectWrapper).ProtoMethods(0xc000e7e6d0, 0xc002095218)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go:150 +0x53
google.golang.org/protobuf/proto.protoMethods(...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/proto/proto_methods.go:18
google.golang.org/protobuf/proto.MarshalOptions.marshal(0xc000000001, 0x0, 0x0, 0x0, 0x93222e0, 0xc000e7e6d0, 0xc000e7e6d0, 0x93222e0, 0xc000e7e6d0, 0x827bf40, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/proto/encode.go:143 +0x49
google.golang.org/protobuf/proto.MarshalOptions.MarshalAppend(0x8000001, 0x0, 0x0, 0x0, 0x9143a00, 0xc000e7e6d0, 0x0, 0x14f790d8, 0x8, 0x7ca0d20, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/proto/encode.go:125 +0x98
github.com/golang/protobuf/proto.marshalAppend(0x0, 0x0, 0x0, 0x14f790d8, 0xc001b04e40, 0x4054000, 0xc001030ba8, 0x0, 0x0, 0xc001030ba8, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/github.com/golang/protobuf/proto/wire.go:40 +0xc7
github.com/golang/protobuf/proto.Marshal(...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/github.com/golang/protobuf/proto/wire.go:23
google.golang.org/grpc/encoding/proto.codec.Marshal(0x827bf40, 0xc001b04e40, 0xc001030ba8, 0xc002095468, 0xc002095468, 0x486316b, 0x7ca0d20)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/grpc/encoding/proto/proto.go:39 +0x5f
google.golang.org/grpc.encode(0x14b9cf40, 0xc000ac60d0, 0x827bf40, 0xc001b04e40, 0xc001380a60, 0xc0020956c8, 0xc000100000, 0x0, 0x0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/grpc/rpc_util.go:592 +0x52
google.golang.org/grpc.prepareMsg(0x827bf40, 0xc001b04e40, 0x14b9cf40, 0xc000ac60d0, 0x0, 0x0, 0x91b6d20, 0xb4fa868, 0x2, 0xc0021bced0, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/grpc/stream.go:1559 +0x107
google.golang.org/grpc.(*clientStream).SendMsg(0xc002735e60, 0x827bf40, 0xc001b04e40, 0x0, 0x0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/grpc/stream.go:740 +0x165
google.golang.org/grpc.invoke(0x91db9e0, 0xc001b04f60, 0x84bd3b3, 0x1d, 0x827bf40, 0xc001b04e40, 0x827c060, 0xc0027fc640, 0xc002279180, 0xc0027fc1c0, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/grpc/call.go:70 +0xe4
github.com/cockroachdb/cockroach/pkg/util/tracing.ClientInterceptor.func2(0x91db9e0, 0xc001b04f60, 0x84bd3b3, 0x1d, 0x827bf40, 0xc001b04e40, 0x827c060, 0xc0027fc640, 0xc002279180, 0x8b4ed88, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/tracing/grpc_interceptor.go:257 +0x158
google.golang.org/grpc.(*ClientConn).Invoke(0xc002279180, 0x91db9e0, 0xc001b04f60, 0x84bd3b3, 0x1d, 0x827bf40, 0xc001b04e40, 0x827c060, 0xc0027fc640, 0x0, ...)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/grpc/call.go:35 +0x109
github.com/cockroachdb/cockroach/pkg/rpc.(*heartbeatClient).Ping(0xc0003de498, 0x91db9e0, 0xc001b04f60, 0xc001b04e40, 0x0, 0x0, 0x0, 0x91db960, 0xc0003ca9c0, 0xc001c0c3a1ccb1d8)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/rpc/heartbeat.pb.go:199 +0xcf
github.com/cockroachdb/cockroach/pkg/rpc.(*Context).runHeartbeat.func3.2(0x91db9e0, 0xc001b04f60, 0x165a0bc00, 0x91db9e0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/rpc/context.go:1161 +0xb8
github.com/cockroachdb/cockroach/pkg/util/contextutil.RunWithTimeout(0x91db9e0, 0xc001b04f60, 0x847a1e0, 0xd, 0x165a0bc00, 0xc000c5ac30, 0x0, 0x0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/contextutil/context.go:140 +0x9e
github.com/cockroachdb/cockroach/pkg/rpc.(*Context).runHeartbeat.func3(0x91db960, 0xc0003ca9c0, 0x40d5669, 0xc000c5ae28)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/rpc/context.go:1166 +0x332
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunTaskWithErr(0xc000b5e540, 0x91db960, 0xc0003ca9c0, 0x847a1e0, 0xd, 0xc000c5ad78, 0x0, 0x0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:331 +0xb2
github.com/cockroachdb/cockroach/pkg/rpc.(*Context).runHeartbeat(0xc00013afc0, 0xc0029119f0, 0xc00189ce10, 0xf, 0xc000ce08a0, 0x0, 0x0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/rpc/context.go:1134 +0x42b
github.com/cockroachdb/cockroach/pkg/rpc.(*Context).grpcDialNodeInternal.func1.1(0x91db960, 0xc0003ca9c0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/rpc/context.go:1054 +0x79
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTask.func1(0xc000b5e540, 0x91db960, 0xc0003ca9c0, 0x0, 0xc002911ae0)
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:352 +0xb9
created by github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTask
        /Users/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:347 +0xfc

I believe the likely cause is grpc/grpc-go#3958.

It isn't immediately necessary to upgrade this dependency, so there is no impact at the moment.

@stevendanna stevendanna added the C-investigation Further steps needed to qualify. C-label will change. label Feb 12, 2021
stevendanna added a commit to stevendanna/cockroach that referenced this issue Feb 18, 2021
This change enables future upgrades of google.golang.org/grpc.

Recent changes to google.golang.org/grpc have changed the default
proto codec such that it is incompatible with gogoproto:

grpc/grpc-go#3958

While `proto.Marshal` does do a check for the Marshal/Unmarshal it
appears to do this through reflection methods that will panic on
fields using gogoproto.nullable.

To avoid this, we install a proto codec that does an interface check
before dispatching to proto.Marshal/proto.Unmarshal.

Note that I haven't replicated the protobuffer caching that previously
existed in google.golang.org/grpc. The referenced change claims
removing the caching may be a small performance win; however, they
also removed the typecheck that we need to do, so it is unclear.

Fixes cockroachdb#60531

Release note: None
stevendanna added a commit to stevendanna/cockroach that referenced this issue Mar 10, 2021
This change enables future upgrades of google.golang.org/grpc.

Recent changes to google.golang.org/grpc have changed the default
proto codec such that it is incompatible with gogoproto:

grpc/grpc-go#3958

While `proto.Marshal` does do a check for the Marshal/Unmarshal it
appears to do this through reflection methods that will panic on
fields using gogoproto.nullable.

To avoid this, we install a proto codec that does an interface check
before dispatching to proto.Marshal/proto.Unmarshal.

Note that I haven't replicated the protobuffer caching that previously
existed in google.golang.org/grpc. The referenced change claims
removing the caching may be a small performance win; however, they
also removed the typecheck that we need to do, so it is unclear.

Fixes cockroachdb#60531

Release note: None
stevendanna added a commit to stevendanna/cockroach that referenced this issue Mar 18, 2021
This change enables future upgrades of google.golang.org/grpc.

Recent changes to google.golang.org/grpc have changed the default
proto codec such that it is incompatible with gogoproto:

grpc/grpc-go#3958

While `proto.Marshal` does do a check for the Marshal/Unmarshal it
appears to do this through reflection methods that will panic on
fields using gogoproto.nullable.

To avoid this, we install a proto codec that does an interface check
before dispatching to proto.Marshal/proto.Unmarshal.

Note that I haven't replicated the protobuffer caching that previously
existed in google.golang.org/grpc. The referenced change claims
removing the caching may be a small performance win; however, they
also removed the typecheck that we need to do, so it is unclear.

Fixes cockroachdb#60531

Release note: None
@knz
Copy link
Contributor

knz commented Mar 18, 2021

how is this issue different in scope from #56378
and #56147 ?

@knz knz added this to To do in DB Server & Security via automation Mar 18, 2021
@stevendanna
Copy link
Collaborator Author

I think the scope of this is different from #56147 although we could certainly choose to fix the problem as part of that work.

Some gogoproto-generated Go code is incompatible with the latest version of google.golang.org/grpc and the version of github.com/golang/protobuf it depends on. This incompatibility exists even using the most recent version of gogoproto. Thus, if we complete #56147 and upgrade gogoproto, we would still see breakage when upgrading google.golang.org/grpc.

The incompatibility exists because the default "codec" in the gRPC library to marshal protobufs no longer does interface checks for custom Marshaler functions (grpc/grpc-go#3958) and assumes that github.com/golang/protobuf/proto.Marshal can handle any protobuf that we may want to marshal. Unfortunately github.com/golang/protobuf/proto.Marshal cannot handle all Gogoproto-generated types.

However, since this issue was originally written, the scope of incompatibility has narrowed. Before, the proto.Marshal function would fail on any field using the gogoproto's support for 'non-nullable' fields. However, their most recent release adds support for "aberrant types" which includes messages with non-nullable fields.

Unfortunately, even with this change, they still don't seem to support gogoproto's customtypes options.

If you currently attempt to upgrade grpc, cockroach demo will likely fail with something like:

panic: invalid Go type uuid.UUID for field cockroach.rpc.PingRequest.origin_cluster_id [recovered]
	panic: invalid Go type uuid.UUID for field cockroach.rpc.PingRequest.origin_cluster_id [recovered]
	panic: invalid Go type uuid.UUID for field cockroach.rpc.PingRequest.origin_cluster_id

goroutine 5764 [running]:
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).Recover(0xc000dbe180, 0x58b4340, 0xc0004604c0)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:233 +0x126
panic(0x424e140, 0xc002a166e0)
	/hab/pkgs/core/go/1.15/20200824091619/src/runtime/panic.go:969 +0x175
github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).Recover(0xc000dbe180, 0x58b4340, 0xc0004604c0)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:233 +0x126
panic(0x424e140, 0xc002a166e0)
	/hab/pkgs/core/go/1.15/20200824091619/src/runtime/panic.go:969 +0x175
google.golang.org/protobuf/internal/impl.newSingularConverter(0x5a0c320, 0x4928620, 0x5a0fb60, 0xc0013c3bc0, 0x5900101, 0xc001e0b8a0)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/convert.go:143 +0xf17
google.golang.org/protobuf/internal/impl.NewConverter(0x5a0c320, 0x4928620, 0x5a0fb60, 0xc0013c3bc0, 0x203000, 0x203000)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/convert.go:60 +0xdc
google.golang.org/protobuf/internal/impl.fieldInfoForScalar(0x5a0fb60, 0xc0013c3bc0, 0x46a4ab4, 0x9, 0x0, 0x0, 0x5a0c320, 0x49f3c00, 0x46a4abf, 0xa4, ...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go:270 +0x11b
google.golang.org/protobuf/internal/impl.(*MessageInfo).makeKnownFieldsFunc(0xc0015abce0, 0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff, 0x0, 0x0, ...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go:80 +0x8bd
google.golang.org/protobuf/internal/impl.(*MessageInfo).makeReflectFuncs(0xc0015abce0, 0x5a0c320, 0x48a92c0, 0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff, ...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go:42 +0x65
google.golang.org/protobuf/internal/impl.(*MessageInfo).initOnce(0xc0015abce0)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message.go:91 +0x185
google.golang.org/protobuf/internal/impl.(*MessageInfo).init(...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message.go:73
google.golang.org/protobuf/internal/impl.(*messageReflectWrapper).ProtoMethods(0xc002a16370, 0xc00239b208)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go:150 +0x53
google.golang.org/protobuf/proto.protoMethods(...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/proto/proto_methods.go:18
google.golang.org/protobuf/proto.MarshalOptions.marshal(0xc002000001, 0x0, 0x0, 0x0, 0x59fd420, 0xc002a16370, 0xc002a16370, 0x59fd420, 0xc002a16370, 0x4885f20, ...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/proto/encode.go:140 +0x49
google.golang.org/protobuf/proto.MarshalOptions.MarshalAppend(0x4000001, 0x0, 0x0, 0x0, 0x58184a0, 0xc002a16370, 0x0, 0x7f16ee67a388, 0x1, 0xc000100800, ...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/google.golang.org/protobuf/proto/encode.go:122 +0x98
github.com/golang/protobuf/proto.marshalAppend(0x0, 0x0, 0x0, 0x7f16ee67a388, 0xc000cf2ae0, 0x4293400, 0x0, 0x0, 0x0, 0x1, ...)
	/home/ssd/go/src/github.com/cockroachdb/cockroach/vendor/github.com/golang/protobuf/proto/wire.go:40 +0xc7
github.com/golang/protobuf/proto.Marshal(...)

You will get this same error even if you regenerate all of the protos with the most recent version of gogoproto (at least, I did in a small local experiment).

One way to fix this is likely the same fix that I've already submitted (although I haven't retested it). However, given the narrower scope of the incompatibility, there may be other paths available to fix it as well.

@knz
Copy link
Contributor

knz commented Mar 19, 2021

thanks for explaining

craig bot pushed a commit that referenced this issue Mar 23, 2021
61333: rpc: install custom proto codec r=[erikgrinaker,pbardea] a=stevendanna

This change enables future upgrades of google.golang.org/grpc.

Recent changes to google.golang.org/grpc have changed the default
proto codec such that it is incompatible with gogoproto:

grpc/grpc-go#3958

While `proto.Marshal` does do a check for the Marshal/Unmarshal it
appears to do this through reflection methods that will panic on
fields using gogoproto.nullable.

To avoid this, we install a proto codec that does an interface check
before dispatching to proto.Marshal/proto.Unmarshal.

Note that I haven't replicated the protobuffer caching that previously
existed in google.golang.org/grpc. The referenced change claims
removing the caching may be a small performance win; however, they
also removed the typecheck that we need to do, so it is unclear.

Fixes #60531

Release note: None

Co-authored-by: Steven Danna <danna@cockroachlabs.com>
@craig craig bot closed this as completed in 5ba160f Mar 23, 2021
DB Server & Security automation moved this from To do to Done 21.1 Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-investigation Further steps needed to qualify. C-label will change.
Projects
None yet
2 participants