Badger: Cannot open DB because the external magic number doesn't match. Deploying Dgraph using Helm Chart

release.yaml:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: dgraph
  namespace: dgraph
spec:
  chart:
    spec:
      chart: dgraph
      sourceRef:
        kind: HelmRepository
        name: dgraph
  interval: 10m
  maxHistory: 3
  values:
    alpha:
      service:
        type: LoadBalancer
      configFile:
        config.yaml: |
          graphql:
            introspection: true
          security:
            whitelist: 10.0.25.0/24,10.0.26.0/24,10.0.27.0/24
    zero:
      service:
        type: LoadBalancer
      configFile:
        config.yaml: |
          security:
            whitelist: 10.0.25.0/24,10.0.26.0/24,10.0.27.0/24
    ratel:
      enabled: true
      image: 
        tag: v21.03.0
      service: 
        type: LoadBalancer
      configFile:
        config.yaml: |
          security:
            whitelist: 10.0.25.0/24,10.0.26.0/24,10.0.27.0/24

Had a Helm release of DGraph using above configuration, with a companion app deployed alongside it that runs custom mutations + other controls. DGraph Alpha suddenly started giving the following error:

I0118 22:33:59.273827      19 query.go:138] Dgraph query execution failed : Dgraph query failed because Dgraph execution failed because context canceled

We’re on a very short timeline, so I figured I would uninstall the Helm Release and redeploy. Upon doing so, zero and ratel are deploying with no errors, but alpha pods are crashing with the following error:

[Sentry] 2022/01/19 02:46:11 Sending fatal event [f986470b736444d29b0f48fdff63df16] to o318308.ingest.sentry.io project: 1805390
2022/01/19 02:46:11 Cannot open DB because the external magic number doesn't match. Expected: 1, version present in manifest: 0

Error while creating badger KV posting store
github.com/dgraph-io/dgraph/x.Checkf
        /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:51
github.com/dgraph-io/dgraph/worker.(*ServerState).initStorage
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:144
github.com/dgraph-io/dgraph/worker.InitServerState
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:78
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.run
        /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:914
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.init.1.func1
        /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:101
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:81
main.main
        /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/main.go:112
runtime.main
        /usr/local/go/src/runtime/proc.go:255
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1581

We are using version 21.03

Seems like you need to delete the pvcs created by the statefulsets that were used by a different version of dgraph. Deleting the helm chart will not delete these, since it did not create them.

I can confirm that the issue was due to pvcs that were created using version 21.03 while trying to deploy a Helm release that was using the latest version. Thank you.