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

binlog: update binlog status from Skippping to On when recover binlog #32173

Merged
merged 9 commits into from
Nov 14, 2022
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
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