go version)?$ go version go1.13.4 darwin/amd64
1.6
I work on an OSS project (https://github.com/smallstep/certificates) that uses a database abstraction layer allowing the user to select different databases at run time. One of our users recently opened a ticket asking us to support badger v2. I thought we might be able to just add badger/v2 as an additional db option, but it appears that when I load v1 and v2 in the same project I get a golang panic because some common code is being instantiated from the init.go of each package.
Currently we have some users who are running badger v1 and other users who would like to start using badger v2. If we could easily support both for a period of time (while we encourage v1 users to migrate) that would be great. But I'm not sure there is any easy way to do this (please let me know if there is). Assuming this isn't possible, do you have any recommendation on a course of action that wouldn't immediately require old users to migrate their DBs?
Hey @dopey, thanks for reporting the issue. I see the following issue while trying to use badger v1.6 and v2 in the same project
go run main.go
panic: proto: duplicate enum registered: pb.ManifestChange_Operation
goroutine 1 [running]:
github.com/golang/protobuf/proto.RegisterEnum(...)
/home/ibrahim/Projects/go/pkg/mod/github.com/golang/[email protected]/proto/properties.go:459
github.com/dgraph-io/badger/v2/pb.init.0()
/home/ibrahim/Projects/go/src/github.com/dgraph-io/badger/pb/pb.pb.go:638 +0x459
This looks like an issue is with the protobuf files that we generate.
Currently we have some users who are running badger v1 and other users who would like to start using badger v2. If we could easily support both for a period of time (while we encourage v1 users to migrate) that would be great. But I'm not sure there is any easy way to do this (please let me know if there is). Assuming this isn't possible, do you have any recommendations on a course of action that wouldn't immediately require old users to migrate their DBs?
As of now, I can't think of a way for you to support both the versions. I'll try to find a fix for this (maybe we're versioning the protobuf file incorrectly?) and get back to you.
@jarifibrahim did you end up digging into this? I have a project where I'd love to use badger v2, but I can't, because one of my dependencies indirectly pulls badger v1. It's an unfortunate situation, as I can't fix the problem directly, and I can't import the current version.
Thank you for fixing this @mvdan. @dopey The fix for this issue is in master. Please do give it a try and let me know how it goes.
Most helpful comment
Hey @dopey, thanks for reporting the issue. I see the following issue while trying to use badger v1.6 and v2 in the same project
This looks like an issue is with the protobuf files that we generate.
As of now, I can't think of a way for you to support both the versions. I'll try to find a fix for this (maybe we're versioning the protobuf file incorrectly?) and get back to you.