vitess.io/vitess@v0.16.2/go/vt/mysqlctl/redo_log.go (about)

     1  /*
     2  Copyright 2022 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package mysqlctl
    18  
    19  import (
    20  	"context"
    21  	"fmt"
    22  )
    23  
    24  func (mysqld *Mysqld) BinaryHasDisableRedoLog() bool {
    25  	return mysqld.capabilities.hasDisableRedoLog()
    26  }
    27  
    28  func (mysqld *Mysqld) DisableRedoLog(ctx context.Context) error {
    29  	return mysqld.ExecuteSuperQuery(ctx, "ALTER INSTANCE DISABLE INNODB REDO_LOG")
    30  }
    31  
    32  func (mysqld *Mysqld) EnableRedoLog(ctx context.Context) error {
    33  	return mysqld.ExecuteSuperQuery(ctx, "ALTER INSTANCE ENABLE INNODB REDO_LOG")
    34  }
    35  
    36  func (mysqld *Mysqld) ProcessCanDisableRedoLog(ctx context.Context) (bool, error) {
    37  	qr, err := mysqld.FetchSuperQuery(ctx, "SELECT variable_value FROM performance_schema.global_status WHERE variable_name = 'innodb_redo_log_enabled'")
    38  	if err != nil {
    39  		// It's possible that the MySQL process can disable redo logging, but
    40  		// we were unable to connect in order to verify. Let's assume not and
    41  		// let the caller decide if they want to retry.
    42  		return false, err
    43  	}
    44  	if len(qr.Rows) == 0 {
    45  		return false, fmt.Errorf("mysqld >= 8.0.21 required to disable the redo log")
    46  	}
    47  	return true, nil
    48  }