Dgraph v21.03 - Superflag JSON config crashes Alpha

Report a Dgraph Bug

What version of Dgraph are you using?

v21.03.0

Have you tried reproducing the issue with the latest release?

yes

What is the hardware spec (RAM, OS)?

Dgraph image (ubuntu 20.04)

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

  1. Deploy Dgraph Alpha with these helm chart values:
    ## helm install test --set image.tag=v21.03.0 --values config.yaml dgraph/dgraph
    alpha:
      configFile:
        config.json: |
          {
            "limit": {
              "query_timeout": "5m",
              "max_retries": -1,
              "mutations": "allow",
              "normalize_node": 10000,
              "query_edge": 1000000
            },
            "alsologtostderr": true,
            "badger": {
              "compression": "snappy"
            },
            "bindall": true,
            "telemetry": {
              "sentry": true,
              "reports": true
            },
            "export": "export",
            "graphql": {
              "introspection": true
            },
            "log_backtrace_at": ":0",
            "logtostderr": true,
            "ludicrous": {
              "enabled": false
            },
            "raft": {
              "pending_proposals": 256,
              "snapshot_after_entries": 10000
            },
            "port_offset": 0,
            "postings": "/dgraph/p",
            "trace": {
              "ratio": 0.01
            },
            "wal": "/dgraph/w"
          }
    

Expected behaviour and actual result.

Actual Behavior

The dgraph alpha pods will fail:

NAME                  READY   STATUS             RESTARTS   AGE
test-dgraph-alpha-0   0/1     CrashLoopBackOff   2          35s
test-dgraph-alpha-1   0/1     Error              2          33s
test-dgraph-alpha-2   0/1     CrashLoopBackOff   2          31s
test-dgraph-zero-0    1/1     Running            0          35s
test-dgraph-zero-1    1/1     Running            0          33s
test-dgraph-zero-2    1/1     Running            0          31s

The error in the logs is this:

github.com/dgraph-io/ristretto/z.(*SuperFlag).GetUint64
	/go/pkg/mod/github.com/dgraph-io/ristretto@v0.0.4-0.20210310100713-a4346e5d1f90/z/flags.go:252
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.run
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:732
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:93
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:78
main.main
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/main.go:99
runtime.main
	/usr/local/go/src/runtime/proc.go:225
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1371

Expected Behavior

The expectation is that Dgraph Alpha would not crash. This works fine with the same configuration expressed in YAML:

alpha:
  configFile:
    config.yaml: |
      limit:
        query_timeout: 5m
        max_retries: -1
        mutations: allow
        normalize_node: 10000
        query_edge: 1000000
      alsologtostderr: true
      badger:
        compression: snappy
      bindall: true
      telemetry:
        sentry: true
        reports: true
      export: export
      graphql:
        introspection: true
      log_backtrace_at: ":0"
      logtostderr: true
      ludicrous:
        enabled: false
      raft:
        pending_proposals: 256
        snapshot_after_entries: 10000
      port_offset: 0
      postings: "/dgraph/p"
      trace:
        ratio: 0.01
      wal: "/dgraph/w"

I tried running this. There’s an earlier log that shows the issue

2021/04/08 14:39:42 strconv.ParseUint: parsing "1e+06": invalid syntax
Unable to parse 1e+06 as uint64 for key: query-edge. Options: query-edge=1e+06; max-pending-queries=10000; mutations-nquad=1000000; disallow-drop=false; query-timeout=5m; max-retries=-1; mutations=allow; normalize-node=10000; txn-abort-after=5m

Looks like this JSON config is converting 1000000 into 1e+06.

You can fix this by setting these ints into strings.

"query_edge": "1000000"

This is pertaining to superflags. The ristretto/z package is where superflags lives and ristretto itself isn’t related here.

As far as I can remember from v20.11 and earlier configurations, I did not have this problem with earlier regular flags, e.g. config.json:

{
  "query_edge_limit": 1000000
}

Fixed: fix(flags): Convert numbers correctly in SuperFlags by ajeetdsouza · Pull Request #7712 · dgraph-io/dgraph · GitHub

2 Likes