Skip to content

Commit

Permalink
check returned errno
Browse files Browse the repository at this point in the history
Signed-off-by: joccau <[email protected]>
  • Loading branch information
joccau authored and ti-chi-bot committed Nov 14, 2022
1 parent 457ef55 commit 96195fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions server/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,22 @@ func (h binlogRecover) ServeHTTP(w http.ResponseWriter, req *http.Request) {
case "reset":
binloginfo.ResetSkippedCommitterCounter()
case "nowait":
binloginfo.DisableSkipBinlogFlag()
err := binloginfo.DisableSkipBinlogFlag()
if err != nil {
writeError(w, err)
return
}
case "status":
default:
sec, err := strconv.ParseInt(req.FormValue(qSeconds), 10, 64)
if sec <= 0 || err != nil {
sec = 1800
}
binloginfo.DisableSkipBinlogFlag()
err = binloginfo.DisableSkipBinlogFlag()
if err != nil {
writeError(w, err)
return
}
timeout := time.Duration(sec) * time.Second
err = binloginfo.WaitBinlogRecover(timeout)
if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions sessionctx/binloginfo/binloginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ func EnableSkipBinlogFlag() {
}

// DisableSkipBinlogFlag disable the skipBinlog flag.
func DisableSkipBinlogFlag() {
func DisableSkipBinlogFlag() error {
if err := statusListener(BinlogStatusOn); err != nil {
logutil.BgLogger().Warn("update binlog status failed", zap.Error(err))
return errors.Trace(err)
}

atomic.StoreUint32(&skipBinlog, 0)
statusListener(BinlogStatusOn)
logutil.BgLogger().Warn("[binloginfo] disable the skipBinlog flag")
return nil
}

// IsBinlogSkipped gets the skipBinlog flag.
Expand Down

0 comments on commit 96195fe

Please sign in to comment.