Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v1.2 - fix(shutdown): Force exit if CTRL-C is caught before initialization (… #6408

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"os/signal"
"strings"
"sync"
"sync/atomic"
"syscall"
"time"

Expand Down Expand Up @@ -74,7 +75,8 @@ var (
startTime = time.Now()

// Alpha is the sub-command invoked when running "dgraph alpha".
Alpha x.SubCommand
Alpha x.SubCommand
initDone uint32
)

func init() {
Expand Down Expand Up @@ -516,6 +518,7 @@ func setupServer() {

glog.Infoln("gRPC server started. Listening on port", grpcPort())
glog.Infoln("HTTP server started. Listening on port", httpPort())
atomic.AddUint32(&initDone, 1)
wg.Wait()
}

Expand Down Expand Up @@ -691,7 +694,13 @@ func run() {
}
numShutDownSig++
glog.Infoln("Caught Ctrl-C. Terminating now (this may take a few seconds)...")
if numShutDownSig == 3 {

switch {
case atomic.LoadUint32(&initDone) < 2:
// Forcefully kill alpha if we haven't finish server initialization.
glog.Infoln("Stopped before initialization completed")
os.Exit(1)
case numShutDownSig == 3:
glog.Infoln("Signaled thrice. Aborting!")
os.Exit(1)
}
Expand All @@ -702,6 +711,8 @@ func run() {
aclCloser := z.NewCloser(1)
go func() {
worker.StartRaftNodes(worker.State.WALstore, bindall)
atomic.AddUint32(&initDone, 1)

// initialization of the admin account can only be done after raft nodes are running
// and health check passes
edgraph.ResetAcl()
Expand Down