fix: use session variables instead of global_variables table as its not available in some installations

pull/8552/head
Luciano Righetti 2022-07-26 11:31:08 +02:00
parent a3c18d0dad
commit 13460b3a7b
No known key found for this signature in database
GPG Key ID: CB91F2A37C557248
1 changed files with 17 additions and 17 deletions

View File

@ -133,52 +133,52 @@ class Server extends AppModel
public $syncTestErrorCodes = array();
const MYSQL_RECOMMENDED_SETTINGS = [
'INNODB_BUFFER_POOL_SIZE' => [
'innodb_buffer_pool_size' => [
'default' => '134217728',
'recommended' => '2147483648',
'explanation' => 'The InnoDB buffer pool is the memory area where caches table and index data reside. It is the most important MySQL setting, in a dedicated server it should be around 3/4 of all the available RAM. In a shared server it should be around 1/2 of the available RAM.',
],
'INNODB_DEDICATED_SERVER' => [
'innodb_dedicated_server' => [
'default' => '0',
'recommended' => '',
'explanation' => 'Set to `1` if the database is running in a dedicated server. The database engine will examine the available memory and dynamically set `innodb_buffer_pool_size`, `innodb_log_file_size`, `innodb_log_files_in_group` and `innodb_flush_method`. It is particularly useful in cloud enviroments that can be auto-scaled.',
],
'INNODB_LOG_FILE_SIZE' => [
'innodb_log_file_size' => [
'default' => '100663296',
'recommended' => '629145600',
'explanation' => 'This parameter determines the fixed size for MySQLs redo logs. Tuning this value affects the crash recovery time and also overall system performance.',
],
'INNODB_LOG_FILES_IN_GROUP' => [
'innodb_log_files_in_group' => [
'default' => '2',
'recommended' => '2',
'explanation' => 'Defines the number of log files in the log group.',
],
'INNODB_CHANGE_BUFFERING' => [
'innodb_change_buffering' => [
'default' => 'none',
'recommended' => 'none',
'explanation' => 'Whether InnoDB performs change buffering, an optimization that delays write operations to secondary indexes so that the I/O operations can be performed sequentially, enabling it causes extremely long shutdown times for upgrades.',
],
'INNODB_IO_CAPACITY' => [
'innodb_io_capacity' => [
'default' => '200',
'recommended' => '1000',
'explanation' => 'Defines the number of I/O operations per second (IOPS) available to InnoDB background tasks, such as flushing pages from the buffer pool and merging data from the change buffer.',
],
'INNODB_IO_CAPACITY_MAX' => [
'innodb_io_capacity_max' => [
'default' => '2000',
'recommended' => '2000',
'explanation' => 'If flushing activity falls behind, InnoDB can flush more aggressively, at a higher rate of I/O operations per second (IOPS) than defined by the `innodb_io_capacity variable`.',
],
'INNODB_STATS_PERSISTENT' => [
'innodb_stats_persistent' => [
'default' => 'ON',
'recommended' => 'ON',
'explanation' => 'Specifies whether InnoDB index statistics are persisted to disk. Otherwise, statistics may be recalculated frequently which can lead to variations in query execution plans.',
],
'INNODB_READ_IO_THREADS' => [
'innodb_read_io_threads' => [
'default' => '4',
'recommended' => '16',
'explanation' => 'The number of I/O threads for read operations in InnoDB.',
],
'INNODB_WRITE_IO_THREADS' => [
'innodb_write_io_threads' => [
'default' => '4',
'recommended' => '4',
'explanation' => 'The number of I/O threads for write operations in InnoDB.',
@ -2778,17 +2778,17 @@ class Server extends AppModel
if ($this->isMysql()) {
$configuration = [];
$dbVariables = $this->query("SELECT VARIABLE_NAME, VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES;");
$dbVariables = $this->query("SHOW VARIABLES;");
$settings = array_keys(self::MYSQL_RECOMMENDED_SETTINGS);
foreach ($dbVariables as $dbVariable) {
if (in_array($dbVariable['GLOBAL_VARIABLES']['VARIABLE_NAME'], $settings)) {
if (in_array($dbVariable['SESSION_VARIABLES']['Variable_name'], $settings)) {
$configuration[] = [
'name' => $dbVariable['GLOBAL_VARIABLES']['VARIABLE_NAME'],
'value' => $dbVariable['GLOBAL_VARIABLES']['VARIABLE_VALUE'],
'default' => self::MYSQL_RECOMMENDED_SETTINGS[$dbVariable['GLOBAL_VARIABLES']['VARIABLE_NAME']]['default'],
'recommended' => self::MYSQL_RECOMMENDED_SETTINGS[$dbVariable['GLOBAL_VARIABLES']['VARIABLE_NAME']]['recommended'],
'explanation' => self::MYSQL_RECOMMENDED_SETTINGS[$dbVariable['GLOBAL_VARIABLES']['VARIABLE_NAME']]['explanation'],
'name' => $dbVariable['SESSION_VARIABLES']['Variable_name'],
'value' => $dbVariable['SESSION_VARIABLES']['Value'],
'default' => self::MYSQL_RECOMMENDED_SETTINGS[$dbVariable['SESSION_VARIABLES']['Variable_name']]['default'],
'recommended' => self::MYSQL_RECOMMENDED_SETTINGS[$dbVariable['SESSION_VARIABLES']['Variable_name']]['recommended'],
'explanation' => self::MYSQL_RECOMMENDED_SETTINGS[$dbVariable['SESSION_VARIABLES']['Variable_name']]['explanation'],
];
}
}