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

Wrong (negative) values in P_S memory summary tables

    XMLWordPrintable

Details

    Description

      If we start MariaDB 10.5 with Performance Schema and all memory instrumentation enabled:

      openxs@ao756:~/dbs/maria10.5$ bin/mysqld_safe --no-defaults --port=3311 --socket=/tmp/mariadb105.sock --performance_schema=1  --performance-schema-instrument='memory/%=ON' &
      [1] 14916
      openxs@ao756:~/dbs/maria10.5$ 201011 13:51:40 mysqld_safe Logging to '/home/openxs/dbs/maria10.5/data/ao756.err'.
      201011 13:51:41 mysqld_safe Starting mariadbd daemon with databases from /home/openxs/dbs/maria10.5/data
      

      we can see negative values reported immediately after startup for memory/innodb/std event:

      openxs@ao756:~/dbs/maria10.5$ bin/mysql --socket=/tmp/mariadb105.sock performance_schema
      Reading table information for completion of table and column names
      You can turn off this feature to get a quicker startup with -A
       
      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Your MariaDB connection id is 3
      Server version: 10.5.7-MariaDB Source distribution
       
      Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
       
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
       
      MariaDB [performance_schema]> select * from memory_summary_by_thread_by_event_name where current_number_of_bytes_used <0\G
      *************************** 1. row ***************************
                         THREAD_ID: 7
                        EVENT_NAME: memory/innodb/std
                       COUNT_ALLOC: 5
                        COUNT_FREE: 29
         SUM_NUMBER_OF_BYTES_ALLOC: 728
          SUM_NUMBER_OF_BYTES_FREE: 1496
                    LOW_COUNT_USED: -24
                CURRENT_COUNT_USED: -24
                   HIGH_COUNT_USED: 1
          LOW_NUMBER_OF_BYTES_USED: -768
      CURRENT_NUMBER_OF_BYTES_USED: -768
         HIGH_NUMBER_OF_BYTES_USED: 32
      1 row in set (0,004 sec)
       
      MariaDB [performance_schema]> select t.*, m.* from memory_summary_by_thread_by_event_name m join threads t on m.thread_id = t.thread_id where current_number_of_bytes_used <0\G
      *************************** 1. row ***************************
                         THREAD_ID: 7
                              NAME: thread/innodb/thread_pool_thread
                              TYPE: BACKGROUND
                    PROCESSLIST_ID: NULL
                  PROCESSLIST_USER: NULL
                  PROCESSLIST_HOST: NULL
                    PROCESSLIST_DB: NULL
               PROCESSLIST_COMMAND: NULL
                  PROCESSLIST_TIME: NULL
                 PROCESSLIST_STATE: NULL
                  PROCESSLIST_INFO: NULL
                  PARENT_THREAD_ID: NULL
                              ROLE: NULL
                      INSTRUMENTED: YES
                           HISTORY: YES
                   CONNECTION_TYPE: Error
                      THREAD_OS_ID: 15007
                         THREAD_ID: 7
                        EVENT_NAME: memory/innodb/std
                       COUNT_ALLOC: 5
                        COUNT_FREE: 29
         SUM_NUMBER_OF_BYTES_ALLOC: 728
          SUM_NUMBER_OF_BYTES_FREE: 1496
                    LOW_COUNT_USED: -24
                CURRENT_COUNT_USED: -24
                   HIGH_COUNT_USED: 1
          LOW_NUMBER_OF_BYTES_USED: -768
      CURRENT_NUMBER_OF_BYTES_USED: -768
         HIGH_NUMBER_OF_BYTES_USED: 32
      1 row in set (0,005 sec)
      

      Negative values (or COUNT_FREE > COUNT_ALLOC) should never happen in this table. Either server does something wrong while getting the results, or there is a bug in instrumentation or we really free some memory that was not allocated.

      I do not see such results from a similar test with MySQL 5.7.30 for example (no wonder, InnoDB implementation is very different and allocation is attributed to MariaDB's unique thread/innodb/thread_pool_thread background thread).

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              valerii Valerii Kravchuk
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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