summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-07-14 13:21:01 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-07-14 13:21:01 +0300
commit8d061996e6531b2809aefb0ed96e0662b2c2882e (patch)
treebd8a073577473c655bcf1771daefe47b304bd38c
parentdc58987eb7112bd60122114abd56e6f9438f457f (diff)
downloadmariadb-git-8d061996e6531b2809aefb0ed96e0662b2c2882e.tar.gz
MDEV-23161 avg_count_reset may wrongly be NULL in I_S.INNODB_METRICS
This issue was originally reported by Fungo Wang, along with a fix, as MySQL Bug #98990. His suggested fix was applied as part of mysql/mysql-server@a003fc373d1adb3ccea353b5d7d83f6c4c552383 and released in MySQL 5.7.31. i_s_metrics_fill(): Add the missing call to Field::set_notnull(), and simplify some code.
-rw-r--r--storage/innobase/handler/i_s.cc27
-rw-r--r--storage/xtradb/handler/i_s.cc27
2 files changed, 28 insertions, 26 deletions
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 894e798ee27..145a5708423 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2019, MariaDB Corporation.
+Copyright (c) 2014, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -2557,7 +2557,7 @@ i_s_metrics_fill(
time_diff = 0;
}
- /* Unless MONITOR__NO_AVERAGE is marked, we will need
+ /* Unless MONITOR_NO_AVERAGE is set, we must
to calculate the average value. If this is a monitor set
owner marked by MONITOR_SET_OWNER, divide
the value by another counter (number of calls) designated
@@ -2565,8 +2565,9 @@ i_s_metrics_fill(
Otherwise average the counter value by the time between the
time that the counter is enabled and time it is disabled
or time it is sampled. */
- if (!(monitor_info->monitor_type & MONITOR_NO_AVERAGE)
- && (monitor_info->monitor_type & MONITOR_SET_OWNER)
+ if ((monitor_info->monitor_type
+ & (MONITOR_NO_AVERAGE | MONITOR_SET_OWNER))
+ == MONITOR_SET_OWNER
&& monitor_info->monitor_related_id) {
mon_type_t value_start
= MONITOR_VALUE_SINCE_START(
@@ -2582,18 +2583,18 @@ i_s_metrics_fill(
fields[METRIC_AVG_VALUE_START]->set_null();
}
- if (MONITOR_VALUE(monitor_info->monitor_related_id)) {
- OK(fields[METRIC_AVG_VALUE_RESET]->store(
- MONITOR_VALUE(count)
- / MONITOR_VALUE(
- monitor_info->monitor_related_id),
- FALSE));
+ if (mon_type_t related_value =
+ MONITOR_VALUE(monitor_info->monitor_related_id)) {
+ OK(fields[METRIC_AVG_VALUE_RESET]
+ ->store(MONITOR_VALUE(count)
+ / related_value, false));
+ fields[METRIC_AVG_VALUE_RESET]->set_notnull();
} else {
fields[METRIC_AVG_VALUE_RESET]->set_null();
}
- } else if (!(monitor_info->monitor_type & MONITOR_NO_AVERAGE)
- && !(monitor_info->monitor_type
- & MONITOR_DISPLAY_CURRENT)) {
+ } else if (!(monitor_info->monitor_type
+ & (MONITOR_NO_AVERAGE
+ | MONITOR_DISPLAY_CURRENT))) {
if (time_diff) {
OK(fields[METRIC_AVG_VALUE_START]->store(
(double) MONITOR_VALUE_SINCE_START(
diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc
index 8d7612ab16d..9813e993411 100644
--- a/storage/xtradb/handler/i_s.cc
+++ b/storage/xtradb/handler/i_s.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2019, MariaDB Corporation.
+Copyright (c) 2014, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -2553,7 +2553,7 @@ i_s_metrics_fill(
time_diff = 0;
}
- /* Unless MONITOR__NO_AVERAGE is marked, we will need
+ /* Unless MONITOR_NO_AVERAGE is set, we must
to calculate the average value. If this is a monitor set
owner marked by MONITOR_SET_OWNER, divide
the value by another counter (number of calls) designated
@@ -2561,8 +2561,9 @@ i_s_metrics_fill(
Otherwise average the counter value by the time between the
time that the counter is enabled and time it is disabled
or time it is sampled. */
- if (!(monitor_info->monitor_type & MONITOR_NO_AVERAGE)
- && (monitor_info->monitor_type & MONITOR_SET_OWNER)
+ if ((monitor_info->monitor_type
+ & (MONITOR_NO_AVERAGE | MONITOR_SET_OWNER))
+ == MONITOR_SET_OWNER
&& monitor_info->monitor_related_id) {
mon_type_t value_start
= MONITOR_VALUE_SINCE_START(
@@ -2578,18 +2579,18 @@ i_s_metrics_fill(
fields[METRIC_AVG_VALUE_START]->set_null();
}
- if (MONITOR_VALUE(monitor_info->monitor_related_id)) {
- OK(fields[METRIC_AVG_VALUE_RESET]->store(
- MONITOR_VALUE(count)
- / MONITOR_VALUE(
- monitor_info->monitor_related_id),
- FALSE));
+ if (mon_type_t related_value =
+ MONITOR_VALUE(monitor_info->monitor_related_id)) {
+ OK(fields[METRIC_AVG_VALUE_RESET]
+ ->store(MONITOR_VALUE(count)
+ / related_value, false));
+ fields[METRIC_AVG_VALUE_RESET]->set_notnull();
} else {
fields[METRIC_AVG_VALUE_RESET]->set_null();
}
- } else if (!(monitor_info->monitor_type & MONITOR_NO_AVERAGE)
- && !(monitor_info->monitor_type
- & MONITOR_DISPLAY_CURRENT)) {
+ } else if (!(monitor_info->monitor_type
+ & (MONITOR_NO_AVERAGE
+ | MONITOR_DISPLAY_CURRENT))) {
if (time_diff) {
OK(fields[METRIC_AVG_VALUE_START]->store(
(double) MONITOR_VALUE_SINCE_START(