dgraph-io / badger

Fast key-value DB in Go.

Home Page:https://dgraph.io/badger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: compilation fails with `GOOS=aix` (Unix)

mohammed90 opened this issue · comments

What version of Badger are you using?

  • github.com/dgraph-io/badger v1.6.2
  • github.com/dgraph-io/badger/v2 v2.2007.4

What version of Go are you using?

Go1.21.5

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, CPU, OS)?

RAM & CPU: Not sure, whatever Github Actions uses (reproduced here).

OS: AIX

What steps will reproduce the bug?

Build with: GOOS=aix GOARCH=ppc64 go build

Expected behavior and actual result.

Expectation:

Successful compilation

Actual result:

# github.com/dgraph-io/badger
dir_unix.go:63:13: undefined: unix.Flock
# github.com/dgraph-io/badger/v2
dir_unix.go:62:13: undefined: unix.Flock

Additional information

The issue is that Badger uses unix.Flock from the golang.org/x/sys/unix, but the referenced function is not available in the referenced dependency for AIX. The syscall exists in AIX, but not exposed/available in the x/sys/unix package. This has been reported upstream (golang/go#64669).

Badger v1 and v2 is an indirect dependency for Caddy, which is how we come across this issue. This was reported by one of the users who was attempting to compile Caddy for AIX (see caddyserver/caddy#5970). This isn't directly an error of badger. We've already reported it upstream (see golang/go#64669). I don't know if you're interested in figuring out a workaround (haven't personally tried any) or prefer to just wait for the Go ticket to be resolved by upstream.

Per the codebase, this issue affects all versions of Badger, including v4. The recommendation is use the mechanism used in this internal package (godoc) of Go cmd: https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/cmd/go/internal/lockedfile/internal/filelock/.

Or you could use rogepeppe package: https://pkg.go.dev/github.com/rogpeppe/go-internal/lockedfile.