SIGSEGV thrown when `praefect['failover_election_strategy']` is set but `praefect['failover_enabled']` is not
If an admin configures an option for praefect['failover_election_strategy']
in /etc/gitlab/gitlab.rb
, but a value for praefect['failover_enabled']
is not, Praefect will perform a nil pointer dereference and throw the error below.
We should bail out and log an error that failover has not been enabled in this scenario.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4fc2a1]
goroutine 98 [running]:
sync.(*Mutex).Lock(...)
/usr/local/go/src/sync/mutex.go:74
database/sql.(*DB).conn(0x0, 0xf30000, 0xc00003a018, 0x7f29f24e8201, 0x0, 0x0, 0x0)
/usr/local/go/src/database/sql/sql.go:1132 +0x41
database/sql.(*DB).query(0x0, 0xf30000, 0xc00003a018, 0xe1e9a9, 0x3b, 0xc0012c0250, 0x1, 0x1, 0xc00132a001, 0x10, ...)
/usr/local/go/src/database/sql/sql.go:1565 +0x66
database/sql.(*DB).QueryContext(0x0, 0xf30000, 0xc00003a018, 0xe1e9a9, 0x3b, 0xc0012c0250, 0x1, 0x1, 0xc0012c01f0, 0x40baeb, ...)
/usr/local/go/src/database/sql/sql.go:1547 +0xd1
database/sql.(*DB).QueryRowContext(...)
/usr/local/go/src/database/sql/sql.go:1648
database/sql.(*DB).QueryRow(0x0, 0xe1e9a9, 0x3b, 0xc0012c0250, 0x1, 0x1, 0x40bdf5)
/usr/local/go/src/database/sql/sql.go:1659 +0x8b
gitlab.com/gitlab-org/gitaly/internal/praefect/nodes.(*sqlElector).lookupPrimary(0xc00071c980, 0xc00071c980, 0x1, 0x0)
/var/cache/omnibus/src/gitaly/internal/praefect/nodes/sql_elector.go:442 +0xbd
gitlab.com/gitlab-org/gitaly/internal/praefect/nodes.(*sqlElector).GetPrimary(0xc00071c980, 0xc0000c2692, 0x8, 0x7f29f24ecd48, 0xc00071c980)
/var/cache/omnibus/src/gitaly/internal/praefect/nodes/sql_elector.go:252 +0x2f
gitlab.com/gitlab-org/gitaly/internal/praefect.ReplMgr.getPrimaryAndSecondaries(0xc0003761c0, 0xf32780, 0xc000be1920, 0xf302c0, 0xc00018c840, 0xf14780, 0xc0001170c0, 0xc0000c2692, 0x8, 0xf37160, ...)
/var/cache/omnibus/src/gitaly/internal/praefect/replicator.go:372 +0x86
gitlab.com/gitlab-org/gitaly/internal/praefect.ReplMgr.ProcessBacklog(0xc0003761c0, 0xf32780, 0xc000be1920, 0xf302c0, 0xc00018c840, 0xf14780, 0xc0001170c0, 0xc0000c2692, 0x8, 0xf37160, ...)
/var/cache/omnibus/src/gitaly/internal/praefect/replicator.go:424 +0x9f
main.run.func2(0xc00018dc20, 0xc0001923c0, 0xf2ffc0, 0xc000de93c0)
/var/cache/omnibus/src/gitaly/cmd/praefect/main.go:283 +0xde
created by main.run
/var/cache/omnibus/src/gitaly/cmd/praefect/main.go:282 +0xb8f