[MDEV-23934] Wrong (negative) values in P_S memory summary tables for memory/sql/global_system_variables Created: 2020-10-11  Updated: 2020-10-18

Status: Confirmed
Project: MariaDB Server
Component/s: Performance Schema
Affects Version/s: 10.5.6, 10.5.7
Fix Version/s: 10.5

Type: Bug Priority: Major
Reporter: Valerii Kravchuk Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None


 Description   

If we start MariaDB 10.5 with performance_schema enabled:

openxs@ao756:~/dbs/maria10.5$ bin/mysqld_safe --no-defaults --port=3311 --socket=/tmp/mariadb105.sock --performance_schema=1 &
[1] 14213
openxs@ao756:~/dbs/maria10.5$ 201011 13:34:47 mysqld_safe Logging to '/home/openxs/dbs/maria10.5/data/ao756.err'.
201011 13:34:47 mysqld_safe Starting mariadbd daemon with databases from /home/openxs/dbs/maria10.5/data

and check memory instrumentation summary tables immediately after start we can see negative values for memory/sql/global_system_variables and main thread:

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_host_by_event_name where current_number_of_bytes_used <0\G
*************************** 1. row ***************************
                        HOST: NULL
                  EVENT_NAME: memory/sql/global_system_variables
                 COUNT_ALLOC: 0
                  COUNT_FREE: 2
   SUM_NUMBER_OF_BYTES_ALLOC: 0
    SUM_NUMBER_OF_BYTES_FREE: 128
              LOW_COUNT_USED: -2
          CURRENT_COUNT_USED: -2
             HIGH_COUNT_USED: 0
    LOW_NUMBER_OF_BYTES_USED: -128
CURRENT_NUMBER_OF_BYTES_USED: -128
   HIGH_NUMBER_OF_BYTES_USED: 0
1 row in set (0,002 sec)
 
MariaDB [performance_schema]> select * from memory_summary_by_thread_by_event_name where current_number_of_bytes_used <0\G
*************************** 1. row ***************************
                   THREAD_ID: 1
                  EVENT_NAME: memory/sql/global_system_variables
                 COUNT_ALLOC: 0
                  COUNT_FREE: 2
   SUM_NUMBER_OF_BYTES_ALLOC: 0
    SUM_NUMBER_OF_BYTES_FREE: 128
              LOW_COUNT_USED: -2
          CURRENT_COUNT_USED: -2
             HIGH_COUNT_USED: 0
    LOW_NUMBER_OF_BYTES_USED: -128
CURRENT_NUMBER_OF_BYTES_USED: -128
   HIGH_NUMBER_OF_BYTES_USED: 0
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: 1
                        NAME: thread/sql/main
                        TYPE: BACKGROUND
              PROCESSLIST_ID: NULL
            PROCESSLIST_USER: NULL
            PROCESSLIST_HOST: NULL
              PROCESSLIST_DB: mysql
         PROCESSLIST_COMMAND: NULL
            PROCESSLIST_TIME: 105
           PROCESSLIST_STATE: NULL
            PROCESSLIST_INFO: NULL
            PARENT_THREAD_ID: NULL
                        ROLE: NULL
                INSTRUMENTED: YES
                     HISTORY: YES
             CONNECTION_TYPE: Error
                THREAD_OS_ID: 14292
                   THREAD_ID: 1
                  EVENT_NAME: memory/sql/global_system_variables
                 COUNT_ALLOC: 0
                  COUNT_FREE: 2
   SUM_NUMBER_OF_BYTES_ALLOC: 0
    SUM_NUMBER_OF_BYTES_FREE: 128
              LOW_COUNT_USED: -2
          CURRENT_COUNT_USED: -2
             HIGH_COUNT_USED: 0
    LOW_NUMBER_OF_BYTES_USED: -128
CURRENT_NUMBER_OF_BYTES_USED: -128
   HIGH_NUMBER_OF_BYTES_USED: 0
1 row in set (0,003 sec)

From the above we seem to see that something was freed twice and never allocated. This is either bug in memory instrumentation, or in the way server gets data from the summary tables, or we really freed some memory that was never allocated (and it may be a more serious bug). We should never see negative values in these tables.



 Comments   
Comment by Elena Stepanova [ 2020-10-18 ]

Should it even show anything at all, given that memory/sql/global_system_variables is not enabled by default in setup_instruments?

Generated at Thu Feb 08 09:26:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.