Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33591

MONITOR_INC_VALUE_CUMULATIVE is executed regardless of "if" condition

Details

    Description

      storage/innobase/buf/buf0flu.cc
      Missing { } brackets:

      if (scanned)
          MONITOR_INC_VALUE_CUMULATIVE(MONITOR_LRU_BATCH_SCANNED,
                                       MONITOR_LRU_BATCH_SCANNED_NUM_CALL,
                                       MONITOR_LRU_BATCH_SCANNED_PER_CALL,
                                       scanned);
      

      MONITOR_INC_VALUE_CUMULATIVE is a multiline macro, so the second statement will be executed always, regardless of “if” condition:

      #define MONITOR_INC_VALUE_CUMULATIVE(                                                                               \
                                      monitor, monitor_n_calls, monitor_per_call, value)      \
                      MONITOR_CHECK_DEFINED(value);                                                                    \
                      if (MONITOR_IS_ON(monitor)) {                                                                               \
                                      MONITOR_VALUE(monitor_n_calls)++;                                               \
                                      MONITOR_VALUE(monitor_per_call) = (mon_type_t) (value);   \
                                      if (MONITOR_VALUE(monitor_per_call)                                               \
                                          > MONITOR_MAX_VALUE(monitor_per_call)) {                             \
                                                      MONITOR_MAX_VALUE(monitor_per_call) =                     \
                                                                      (mon_type_t) (value);                                   \
                                      }                                                                                                               \
                                      MONITOR_VALUE(monitor) += (mon_type_t) (value);                    \
                                      if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) {  \
                                                      MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
                                      }                                                                                                               \
                      }
      

      Attachments

        Issue Links

          Activity

            yury.chaikou Yury Chaikou created issue -
            yury.chaikou Yury Chaikou made changes -
            Field Original Value New Value
            Description storage/innobase/buf/buf0flu.cc
            {code:c++}
            if (scanned)
                MONITOR_INC_VALUE_CUMULATIVE(MONITOR_LRU_BATCH_SCANNED,
                                             MONITOR_LRU_BATCH_SCANNED_NUM_CALL,
                                             MONITOR_LRU_BATCH_SCANNED_PER_CALL,
                                             scanned);
            {code}

            MONITOR_INC_VALUE_CUMULATIVE is a multiline macro, so the _second_ statement will be executed always, regardless of “if” condition:

            {code:c++}
            #define MONITOR_INC_VALUE_CUMULATIVE( \
                                            monitor, monitor_n_calls, monitor_per_call, value) \
                            MONITOR_CHECK_DEFINED(value); \
                            if (MONITOR_IS_ON(monitor)) { \
                                            MONITOR_VALUE(monitor_n_calls)++; \
                                            MONITOR_VALUE(monitor_per_call) = (mon_type_t) (value); \
                                            if (MONITOR_VALUE(monitor_per_call) \
                                                > MONITOR_MAX_VALUE(monitor_per_call)) { \
                                                            MONITOR_MAX_VALUE(monitor_per_call) = \
                                                                            (mon_type_t) (value); \
                                            } \
                                            MONITOR_VALUE(monitor) += (mon_type_t) (value); \
                                            if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
                                                            MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
                                            } \
                            }
            {code}
            storage/innobase/buf/buf0flu.cc
            Missing { } brackets:

            {code:c++}
            if (scanned)
                MONITOR_INC_VALUE_CUMULATIVE(MONITOR_LRU_BATCH_SCANNED,
                                             MONITOR_LRU_BATCH_SCANNED_NUM_CALL,
                                             MONITOR_LRU_BATCH_SCANNED_PER_CALL,
                                             scanned);
            {code}

            MONITOR_INC_VALUE_CUMULATIVE is a multiline macro, so the _second_ statement will be executed always, regardless of “if” condition:

            {code:c++}
            #define MONITOR_INC_VALUE_CUMULATIVE( \
                                            monitor, monitor_n_calls, monitor_per_call, value) \
                            MONITOR_CHECK_DEFINED(value); \
                            if (MONITOR_IS_ON(monitor)) { \
                                            MONITOR_VALUE(monitor_n_calls)++; \
                                            MONITOR_VALUE(monitor_per_call) = (mon_type_t) (value); \
                                            if (MONITOR_VALUE(monitor_per_call) \
                                                > MONITOR_MAX_VALUE(monitor_per_call)) { \
                                                            MONITOR_MAX_VALUE(monitor_per_call) = \
                                                                            (mon_type_t) (value); \
                                            } \
                                            MONITOR_VALUE(monitor) += (mon_type_t) (value); \
                                            if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
                                                            MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
                                            } \
                            }
            {code}

            Thank you for the report. This actually affects MariaDB Server 10.5 already.

            marko Marko Mäkelä added a comment - Thank you for the report. This actually affects MariaDB Server 10.5 already.
            marko Marko Mäkelä made changes -
            Component/s Storage Engine - InnoDB [ 10129 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.0 [ 28320 ]
            Fix Version/s 11.1 [ 28549 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.4 [ 29301 ]
            Affects Version/s 10.5 [ 23123 ]
            Affects Version/s 10.6 [ 24028 ]
            Affects Version/s 10.11 [ 27614 ]
            Affects Version/s 11.0 [ 28320 ]
            Affects Version/s 11.1 [ 28549 ]
            Affects Version/s 11.2 [ 28603 ]
            Affects Version/s 11.3 [ 28565 ]
            Affects Version/s 11.4 [ 29301 ]
            Assignee Marko Mäkelä [ marko ]

            The first bug in this area was introduced by MDEV-15053.

            marko Marko Mäkelä added a comment - The first bug in this area was introduced by MDEV-15053 .
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            issue.field.resolutiondate 2024-03-22 14:52:07.0 2024-03-22 14:52:06.988
            marko Marko Mäkelä made changes -
            Fix Version/s 10.5.25 [ 29626 ]
            Fix Version/s 10.6.18 [ 29627 ]
            Fix Version/s 10.11.8 [ 29630 ]
            Fix Version/s 11.0.6 [ 29628 ]
            Fix Version/s 11.1.5 [ 29629 ]
            Fix Version/s 11.2.4 [ 29631 ]
            Fix Version/s 11.4.2 [ 29633 ]
            Fix Version/s 11.5.1 [ 29634 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.0 [ 28320 ]
            Fix Version/s 11.1 [ 28549 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.4 [ 29301 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]

            People

              marko Marko Mäkelä
              yury.chaikou Yury Chaikou
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.