etcd-io / etcd

Distributed reliable key-value store for the most critical data of a distributed system
https://etcd.io
Apache License 2.0
47.93k stars 9.79k forks source link

option go_package in proto files #18341

Open semyon-dev opened 4 months ago

semyon-dev commented 4 months ago

What would you like to be added?

There has been a commit in the main branch for at least 10 months that adds option go_package: https://github.com/etcd-io/etcd/blob/main/server/storage/wal/walpb/record.proto#L7

But the latest version (v3.5.14) does not have this option, please add this option (or commit) to the next version.

Why is this needed?

I am using two dependencies (one of them is etcd) that have the same proto files - record.proto, and because of this there is a conflict. To resolve this conflict, option go_package is needed.

Now I have to do this: os.Setenv("GOLANG_PROTOBUF_REGISTRATION_CONFLICT", "ignore") or I will get a panic:

panic: proto: file "record.proto" is already registered
See https://protobuf.dev/reference/go/faq#namespace-conflict

goroutine 1 [running]:
google.golang.org/protobuf/reflect/protoregistry.init.func1({0x7ff6c0cc8e90?, 0x7ff6c111ba40?}, {0x7ff6c1716f60, 0xc00031d2b0})
    C:/Users/user/go/src/github.com/pkg/mod/google.golang.org/protobuf@v1.34.2/reflect/protoregistry/registry.go:56 +0x1ec
google.golang.org/protobuf/reflect/protoregistry.(*Files).RegisterFile(0xc000008ed0, {0x7ff6c1746458, 0xc000331880})
    C:/Users/user/go/src/github.com/pkg/mod/google.golang.org/protobuf@v1.34.2/reflect/protoregistry/registry.go:130 +0xbc3
google.golang.org/protobuf/internal/filedesc.Builder.Build({{0x0, 0x0}, {0xc00032f600, 0x11d, 0x200}, 0x0, 0x2, 0x0, 0x0, {0x7ff6c171e9b0, ...}, ...})
    C:/Users/user/go/src/github.com/pkg/mod/google.golang.org/protobuf@v1.34.2/internal/filedesc/build.go:112 +0x1d6
github.com/golang/protobuf/proto.RegisterFile({0x7ff6c115751a, 0xc}, {0x7ff6c0c48940, 0xea, 0xea})
    C:/Users/user/go/src/github.com/pkg/mod/github.com/golang/protobuf@v1.5.4/proto/registry.go:48 +0x148
go.etcd.io/etcd/server/v3/wal/walpb.init.1()
    C:/Users/user/go/src/github.com/pkg/mod/go.etcd.io/etcd/server/v3@v3.5.14/wal/walpb/record.pb.go:119 +0x34

Process finished with the exit code 2
ahrtr commented 4 months ago

But the latest version (v3.5.14) does not have this option, please add this option (or commit) to the next version.

Have you confirmed that it's working if you depend on etcd main branch?

semyon-dev commented 4 months ago

But the latest version (v3.5.14) does not have this option, please add this option (or commit) to the next version.

Have you confirmed that it's working if you depend on etcd main branch?

I'm sorry, the problem remained on the main branch, but I don't understand why

ahrtr commented 4 months ago

the problem remained on the main branch, but I don't understand why

Thanks for the feedback. It means that it won't hep to backport the option go_package change to 3.5.

I suggest you to raise this issue/question in protobuf community. https://github.com/protocolbuffers/protobuf-go

ahrtr commented 4 months ago

Based on https://protobuf.dev/reference/go/faq/#namespace-conflict, it's a best practice to specify a package name in .proto file. So let's keep this ticket open until the root cause is clear.