Dgraph Alpha Passes Invalid Options to Badger


Report a Dgraph Bug

If you pass invalid badger options, dgraph will pass this to badger, and give user feedback as a stacktrace.

What version of Dgraph are you using?

v20.03.1

Have you tried reproducing the issue with the latest release?

not yet

What is the hardware spec (RAM, OS)?

Amazon Linux

Steps to reproduce the issue (command/config used to run Dgraph).

Start dgraph alpha with an invalid badger confgiuration, such as badger.vlog=ram

config.toml

mutations = 'disallow'
export = 'myexport'

[badger]
tables = 'ram'
vlog = 'ram'

Expected behavior and actual result.

If there was an invalid option, feedback to the user that the option is invalid, not pass the invalid option to badger.

The results from this are:

I0721 21:49:49.595335      17 server_state.go:75] Setting Badger Compression Level: 3
I0721 21:49:49.595346      17 server_state.go:84] Setting Badger table load option: ram
I0721 21:49:49.595351      17 server_state.go:96] Setting Badger value log load option: ram
2020/07/21 21:49:49 Invalid Badger Value log options
github.com/dgraph-io/dgraph/x.Fatalf
	/ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:114
github.com/dgraph-io/dgraph/worker.setBadgerOptions
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:103
github.com/dgraph-io/dgraph/worker.(*ServerState).initStorage
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:126
github.com/dgraph-io/dgraph/worker.InitServerState
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:57
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.run
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:612
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.init.2.func1
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:90
github.com/spf13/cobra.(*Command).execute
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830
github.com/spf13/cobra.(*Command).ExecuteC
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
github.com/spf13/cobra.(*Command).Execute
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/dgraph-io/dgraph/dgraph/cmd.Execute
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:70
main.main
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/main.go:78
runtime.main
	/usr/local/go/src/runtime/proc.go:203
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1373

Also, server_state.go marks this an Info log entry instead of an Error log entry.

I think badger should have an API to validate the options. I don’t think this should be done inside Dgraph.

1 Like