Skip to content

Commit

Permalink
binlog: update binlog status from Skippping to On when recover binlog (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jan 10, 2023
1 parent 7302820 commit 1e39e33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions server/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,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
8 changes: 7 additions & 1 deletion sessionctx/binloginfo/binloginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +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)
logutil.BgLogger().Warn("[binloginfo] disable the skipBinlog flag")
return nil
}

// IsBinlogSkipped gets the skipBinlog flag.
Expand Down

0 comments on commit 1e39e33

Please sign in to comment.