Skip to content

Commit

Permalink
Update the signal type pbench handles
Browse files Browse the repository at this point in the history
It should be SIGTERM, SIGINT, and SIGQUIT
  • Loading branch information
ethanyzhang committed Jun 20, 2024
1 parent f21bf29 commit 4a2ae07
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions cmd/loadjson/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"pbench/utils"
"reflect"
"sync"
"syscall"
"time"
)

Expand Down Expand Up @@ -60,8 +61,8 @@ func Run(_ *cobra.Command, args []string) {
log.Info().Int("parallelism", Parallelism).Send()
ctx, cancel := context.WithCancel(context.Background())
timeToExit := make(chan os.Signal, 1)
signal.Notify(timeToExit, os.Interrupt, os.Kill)
// Handle SIGKILL and SIGINT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
// Handle SIGINT, SIGTERM, and SIGQUIT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
go func() {
sig := <-timeToExit
if sig != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"pbench/presto"
"pbench/utils"
"sync"
"syscall"
"time"
)

Expand Down Expand Up @@ -43,8 +44,8 @@ func Run(_ *cobra.Command, args []string) {

ctx, cancel := context.WithCancel(context.Background())
timeToExit := make(chan os.Signal, 1)
signal.Notify(timeToExit, os.Interrupt, os.Kill)
// Handle SIGKILL and SIGINT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
// Handle SIGINT, SIGTERM, and SIGQUIT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
go func() {
sig := <-timeToExit
if sig != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/save/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"pbench/utils"
"strings"
"sync"
"syscall"
"time"
)

Expand Down Expand Up @@ -46,8 +47,8 @@ func Run(_ *cobra.Command, args []string) {
log.Info().Int("parallelism", Parallelism).Send()
ctx, cancel := context.WithCancel(context.Background())
timeToExit := make(chan os.Signal, 1)
signal.Notify(timeToExit, os.Interrupt, os.Kill)
// Handle SIGKILL and SIGINT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
// Handle SIGINT, SIGTERM, and SIGQUIT. When ctx is canceled, in-progress MySQL transactions and InfluxDB operations will roll back.
go func() {
sig := <-timeToExit
if sig != nil {
Expand Down
3 changes: 2 additions & 1 deletion stage/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strconv"
"sync"
"sync/atomic"
"syscall"
"time"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -131,7 +132,7 @@ func (s *Stage) Run(ctx context.Context) int {
results := make([]*QueryResult, 0, len(s.Queries)+len(s.QueryFiles))
s.States.resultChan = make(chan *QueryResult, 16)
timeToExit := make(chan os.Signal, 1)
signal.Notify(timeToExit, os.Interrupt, os.Kill)
signal.Notify(timeToExit, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
// Each goroutine we spawn will increment this wait group (count-down latch). We may start a goroutine for running
// a benchmark stage, or write query output to disk asynchronously.
// This wait group is propagated to the descendant stages.
Expand Down

0 comments on commit 4a2ae07

Please sign in to comment.